Is there any reason why you need to present your landscape orientation as modal in a separate controller? When I have two completely different views on my portrait and landscape orientations, I disappear between them when they are stretched during rotation.
This allows you to significantly distinguish between content in both orientations, a good transition between them and common code under one controller.
Here is the code. When the orientation changes, our UIViewController will switch between PortraitView and LandscapeView .
portraitView and landscape Note are children of the UIViewController view . The hierarchy is as follows:
UIViewController | - view | |- portraitView | |- landscapeView
Both have their autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight so that they stretch as the view adjuster rotates.
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { if( orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight ) { [UIView animateWithDuration:duration animations:^ {
Your controls and sub-items will disappear and be deactivated along with the corresponding views, allowing you to have completely different content. I used this recently to fade between two different background images when changing orientation. The effect is very smooth.
Now you can create your own two view controllers, A and B , which control the two views, as described above. Then you can simply click on the view controllers as usual and not worry about controlling the stack of the UINavigationController view controller during rotation.
source share