Separate names with a comma.
Discussion in 'iOS Programming' started by Duke Leto, Jul 9, 2008.
Is it possible (in IB) to set a different view for landscape mode than for portrait?
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.
Yeah I was thinking about doing it programmatically.. it would just be easier for prototyping purposes to be able to do that..
I dont really understand the question. mind being a little more specific?
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).
Exactly what I meant.
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.
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.
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.
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!