Reputation: 77596
I am trying to have every viewController to display different layout depending on the screen orientation?
What is the best way to move items around?
Please explain
Upvotes: 0
Views: 1028
Reputation: 1140
If it is feasible with your layout, I would make it in code. That way if you have any static elements that are on both layouts you can take advantage of the rotating animation.
If it is not feasible to do this, you can use two use by using a subview. Have 3 xibs. Your main one with any elements on both orientations. Have a view inside this view, and load from two other xibs portrait and landscape layouts.
Upvotes: 2
Reputation: 13267
It would be best to have two different XIB files. Here is some code:
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
//show portrait XIB here
} else {
//show landscape XIB here
}
}
Upvotes: 0