[iPhone IB] Landscape View

Discussion in 'iPhone/iPad Programming' started by Duke Leto, Jul 9, 2008.

  1. macrumors regular

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

    Joined:
    Apr 28, 2008
    #2
    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. thread starter macrumors regular

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

    WPB2

    Joined:
    Jul 1, 2008
    Location:
    Southeast, LA
    #4
    I dont really understand the question. mind being a little more specific?
     
  5. macrumors 6502

    Joined:
    Apr 28, 2008
    #5
    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. thread starter macrumors regular

    Joined:
    Mar 17, 2008
    #6
    Exactly what I meant.
     
  7. macrumors 6502

    Joined:
    Apr 28, 2008
    #7
    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. thread starter macrumors regular

    Joined:
    Mar 17, 2008
    #8
    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. macrumors member

    Joined:
    Mar 25, 2002
    #9
    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.

    ---gralem
     

    Attached Files:

  10. macrumors member

    Joined:
    Jul 12, 2006
    #10
    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