1

I am currently developing an application that works with iOS 5 and iOS 6. Most of my views are only on Portrait orientation except for 1.

RotationNavigationController : Main UINavigationController that overrides supportedInterfaceOrientation and shouldAutorotate.

PageViewController : Pushed in RotationNavigationController and is displayed in Portrait orientation only.

ImageViewController : Pushed after PageViewController. Is displayed with UIInterfaceOrientationMaskAllButUpsideDown.

Here's what I have in the ImageViewController's ViewDidLoad

- (void)viewDidLoad
{
   // currentMask is the value returned by supportedInterfaceOrientation
   [(RotationNavigationController*)self.navigationController setCurrentMask:UIInterfaceOrientationMaskAllButUpsideDown];
   [(RotationNavigationController*)self.navigationController setShouldAutorotate:YES];
}

And when I popViewController from ImageViewController in landscape, I get back to PageViewController in landscape mode too whereas PageViewController only supports Portrait orientation.

Of course, I reset the mask in the ImageViewController's viewWillDisappear to Portrait.

Is there a way for PageViewController to remain in Portrait orientation ?

Snaker
  • 735
  • 9
  • 20
  • 1
    This has been discussed (and seems nontrivial) at http://stackoverflow.com/questions/12640870/ios-6-force-device-orientation-to-landscape – emrys57 Nov 28 '12 at 12:30

1 Answers1

0

Thanks for the link emrys57. I found out the solution down there, and it was quite trivial in the end :

In RotationNavigationController, just add the following method :

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}
Snaker
  • 735
  • 9
  • 20