I think this question should've been asked a million times by now, but I still can't find an answer to this.
Here's my hierarchy: UINavigationController -> UIViewController 1 ->(push)-> UIViewController 2
UINavigationController: supports all possible orientation UIViewController 1: supports only portrait UIViewController 2: supports only landscape
How can I lock UIViewController 1 into portrait only and at the same time lock UIViewController 2 into landscape only? Is it even possible? So far what I see is that UIViewController 2 always takes the orientation of UIViewController 1.
Note, that this is for iOS 6 only.
Thanks!
Make the app support only portrait mode and add the following line to the initWithNibName of UIViewController 2
Add new Objective-C class (subclass of UINavigationController) and add the following code to the .m files
After you added the new classes go to your ViewController classes and make the following changes
In the shouldAutorotate , shouldAutorotateToInterfaceOrientation: return YES if you want the ViewController to be supporting Multiple orientation else return NO , also in houldAutorotateToInterfaceOrientation: method pass the Orintation you want for that specific ViewController , Repeat the same for all the view controllers .
Reason of doing this:-
1:Although you can change the preferredInterfaceOrientationForPresentation: of any viewController to a specific orientation but since you are using the UINavigationController you also need to override the supportedInterfaceOrientations for your UINavigationController
2:In order the override the supportedInterfaceOrientations for UINavigationController we have subclassed UINavigationController and modified the method related to the UINavigation Orientation.
Hope it will help you !
I am also find the same problem.i have found that shouldAutorotate function not call every time so i change orientation programmatic
first import this
then
hope this help you.