You must lock the controller in your RootViewController(eg.UITabbarController or UINavigationController) . When your device rotate,First It will call AppDelegate's rotateMethod(eg.- (BOOL)shouldAutorotate , - (NSUInteger)supportedInterfaceOrientations).Then It call RootViewController's RotateMehod.
1.If your RootViewController is UITabbarController, add code like following code in your UITabbarController(NotRotateController is the controller your do not want go to landscape mode )
#import "NotRotateController.h"
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
UINavigationController * baseNavCtr = self.viewControllers[self.selectedIndex];
if ([baseNavCtr.topViewController isKindOfClass:[NotRotateController class]]) {
return UIInterfaceOrientationMaskPortrait;
}else {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
}
2.If your RootViewController is UINavigationContoller
#import "NotRotateController.h"
- (NSUInteger)supportedInterfaceOrientations
{
if (self.topViewController isKindOfClass:[NotRotateController class]) {
return UIInterfaceOrientationMaskPortrait;
}else {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
}
- (BOOL)shouldAutorotate {
return YES;
}
3.Summarize, judge your the Controller in RootViewController' - (NSUInteger)supportedInterfaceOrientations
method ,return the orientation your want to surport