THIS IS NOT A DUPLICATE QUESTION. A final working solution has NOT been provided yet so please do not close this question until we've accepted an answer or found and provided our own 100% working solution. Thanks!
==================================================================
Using Xcode 4.5.1, we have a tab-bar app with 5 tabs in it. Each tab contains a UINavigationController, so the entire App thus needs to be viewed in Portrait mode. There is one exception: an "image-gallery" type view controller that we need to open and be viewed full-screen, and in LANDSCAPE mode.
We were able to do this easily in iOS5 using the following code in that one particular ViewController:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
But shouldAutorotateToInterfaceOrientation
has been deprecated in iOS6 and doesn't work any more.
So, to get this to work in iOS6, we've taken the following steps so far:
1) created a subclass of the UITabBarController (which is our rootViewController)
2) set its supportedInterfaceOrientations
and preferredInterfaceOrientationForPresentation
to UIInterfaceOrientationMaskPortrait
(But note that we are NOT implementing the shouldAutorotate
method in it)
3) Set the PROJECT/Target supported orientations to ALL
This ALMOST works perfectly: our "Image Gallery" ViewController does respond to both landscape modes - as it should - but it still initially opens in Portrait - which is bad. We need it to open up right in Landscape - and not ever be able to be displayed in Portrait. Right now it still doing both.
Any idea why its doing that - or how to fix it?