Modelling rotation in Interface Builder

Discussion in 'Mac Programming' started by RossOliver, Jun 11, 2008.

  1. RossOliver macrumors regular

    Nov 6, 2006

    Upon creating a new window in IB, I now notice the little arrow in the top right corner allowing rotation to be simulated. It works great for some of my views, resizing my buttons for me and what not, but on others I need to change the size of a component when it is rotated to landscape (and obviously change it back when it's rotated to portrait).

    I can't see any way to create state between the two orientations - changing a component in one orientation changes it in both... is there a way to give it state in IB so it knows which way up it is and how to display a component when it is that way up?

    Also, how do I get this nice rotation simulation in an XIB containing only a view (no window)?

  2. RossOliver thread starter macrumors regular

    Nov 6, 2006
    I take it that this can't be achieved in Interface Builder yet then? Is it likely to appear in the final release or is it something that will only every be achieved programmatically?
  3. Sbrocket macrumors 65816


    Jun 3, 2007
    This is something you'd want to do programmatically. In truth, Interface Builder can only do simple things and whenever you need to do stuff like animation you're going to need to go back to code. This is the reason all the WWDC sessions show the code method needed in order to achieve different things rather than just dragging some objects around in IB. IB can be a useful tool (though I haven't really thought its worth in while for UIKit yet), but you always want to know how to do things programmatically and what the equivalent code would be for each of your actions in IB. It can only help you.

    UIView cannot auto-rotate - you need a UIViewController in order to catch the rotation notifications, which the UIWindow object in IB presumably creates to manage the window's view.
  4. liptonlover macrumors 6502a

    Mar 13, 2008
    we're talking about an iphone window right?
    You need to learn how to use the auto resize features in IB. By utilizing those options properly your buttons will behave properly when you rotate the view.

Share This Page