0

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?

Community
  • 1
  • 1
Taskinul Haque
  • 724
  • 2
  • 16
  • 36

1 Answers1

0

Given 1. the reply you have given to my comment, 2. you have tried the solution suggested below:

iOS 6: How do I restrict some views to portrait and allow others to rotate?

what I perceive, you have same/common property LandscapeOK accessible across all controllers.

I suggest you to debug and check value of LandscapeOK inside supportedInterfaceOrientations, when you naviagte back to controller 2 from Controller 3.

Community
  • 1
  • 1
Macrosoft-Dev
  • 2,195
  • 1
  • 12
  • 15