I have a hierarchy of 3 views
I've created a subclass for my NavigationViewController, and setup a property Landscape
which determines whether each viewController can support different orientations.
This property is set in the ViewWillAppear
of each View controller: this works perfectly. Controller 1 and 2 are portrait only, and controller 3 supports both portrait and landscape orientations.
The issue arrises when I'm going back popping
controller 3 to go back to controller 2
IF i'm in controller 3 in landscape orientation, and I click the back button, my Controller 2 is presented to me in Landscape orientation : (controller 2 does not support Landscape)
Then i have to rotate the device for the orientation to fix itself . . . .
code in Navigation Controller - (BOOL)shouldAutorotate { return YES; }
- (NSUInteger)supportedInterfaceOrientations
{
if (LandscapeOK) {
// for iPhone, you could also return UIInterfaceOrientationMaskAllButUpsideDown
return UIInterfaceOrientationMaskAll;
} else {
return UIInterfaceOrientationMaskPortrait;
}
Code at Each ViewControllers ViewWillAppear
Method
[(NavigationViewController *)[self navigationController] setLandscape:YES];
I have my code set up almost exactly the same way as this question: the same problem as well. Question was posted a year or so back but yet no appropriate solution - while going through the answers listed
iOS 6: How do I restrict some views to portrait and allow others to rotate?