[iPhone IB] Landscape View

Discussion in 'iOS Programming' started by Duke Leto, Jul 9, 2008.

  1. Duke Leto macrumors regular

    Mar 17, 2008
    Is it possible (in IB) to set a different view for landscape mode than for portrait?
  2. Enuratique macrumors 6502

    Apr 28, 2008
    I don't know about in Interface Builder. You can build your two separate views (landscape and portrait) in IB and then programatically switch the two in response to orientation change events.

    Don't know if this is what you were looking for.
  3. Duke Leto thread starter macrumors regular

    Mar 17, 2008
    Yeah I was thinking about doing it programmatically.. it would just be easier for prototyping purposes to be able to do that..
  4. WPB2 macrumors 6502a


    Jul 1, 2008
    Southeast, LA
    I dont really understand the question. mind being a little more specific?
  5. Enuratique macrumors 6502

    Apr 28, 2008
    I think what he means is having a different view based on the orientation of the iPhone - like the new calculator which switches into scientific mode (more buttons, etc) when in landscape mode. This is easier to do with two separate views than to try and redraw one view with more buttons and what not. He was wondering if there was any way to simulate this in IB (I think).
  6. Duke Leto thread starter macrumors regular

    Mar 17, 2008
    Exactly what I meant.
  7. Enuratique macrumors 6502

    Apr 28, 2008
    Unfortunately, I don't know if this is doable entirely within IB. In my experience, IB is great for laying out the UI and hooking up outlets and delegates, but for anything more advanced, such as this, you gotta rely on code. I'm not saying it can't be done, I just don't know of a way.
  8. Duke Leto thread starter macrumors regular

    Mar 17, 2008
    Thats fine with me. I still have a lot of work in design and such, but I'll make sure to "enclose" the tableview and toolbars in a UIView so that when I rotate, I can clear it or redraw into it. Maybe I can even have two separate nibs, which are changed out when it is rotated. Well I have my hands full for now, but that knowledge helps in the design process.
  9. gralem macrumors member

    Mar 25, 2002
    There is a little rotating-arrow on the right-side of the window titlebar in Interface Builder. Click on that and you will be working in landscape mode. Is this what you are looking for? Then have 2 views, like "MainView.xib" and "MainViewLandscape.xib". You will switch xibs somewhere in the view controller (like in [willRotateToInterfaceOrientation:duration:] or [didRotateFromInterfaceOrientation:]). There is a section in the UIViewController document on "Handling Rotations".

    Hope this helps.


    Attached Files:

  10. jasonbrennan macrumors member

    Jul 12, 2006
    I'm having trouble doing just this. I am not using IB, but I have two UIViewControllers, and I'm trying to get rotation working like how it works in the iPod app.

    I have some methods overridden (including the ones you've mentioned) and I can get one view to show after the rotation, but rotating back causes problems.

    The main problem is my first (portrait) controller is/has a UINavController, and when I rotate, I don't want a nav controller. I've tried doing something like [self.navigationController.parentViewController setView:myLandscapeView];, but when I go back, I don't know how to restore the old view...it's madness. Any help would be great!

Share This Page