In my app i've both tabbar and navigationBar. rootview controller tabbar and tabbar has 4 navigation controller.
I want to make some viewcontrollers to be portrait only. It may be a common question but I've tried enough but I could not solve this.
How to make portrait orientation for some view Controller?
I've solved this problem and answering so that if someone face same problem they can get a help.
The above methods don't get called of a viewcontroller if they are inside any tabbarcontroller of navigationcontroller. If these methods are declared inside tabbarcontroller or navigation controller then they will get called. In my case the viewcontrollers was inside navigationcontroller and the navigation controllers are inside a tabbarcontroller.
For solving this I make a class FixedOrientationTab, it is a subclass of UITabBarController, and a navigation class OrientationEnabledNavigation, it is a subclass of UINavigationController. Then I implemented
shouldAutorotate, supportedInterfaceOrientations, preferredInterfaceOrientationForPresentation
methods inside FixedOrientationTab and OrientationEnabledNavigation.OrientationEnabledNavigation.h
OrientationEnabledNavigation.m
FixedOrientationTab.h
FixedOrientationTab.m
Then if you want to use navigation controller in your project then use OrientationEnabledNavigation and for tabbar FixedOrientationTab. After that if you implement
shouldAutorotate, supportedInterfaceOrientations, preferredInterfaceOrientationForPresentation
these method inside your viewcontroller then they will get called.Hope this helps.. :)