In the project, I want all view controllers will be portrait but just two or three of them will be able to rotate. Those view controllers will support both landscape and portrait orientation. To achieve that i subclassed UINavigationController.
and in the view controller that i want it to be portrait only i wrote that.
but this View controller still rotates. What is wrong here?
Code:
@implementation MyNavigationController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (BOOL)shouldAutorotate {
return self.topViewController.shouldAutorotate;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return [[self topViewController] supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return [self.topViewController preferredInterfaceOrientationForPresentation];
}
@end
Code:
- (UIInterfaceOrientationMask) supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
- (BOOL)shouldAutorotate {
return false;
}
but this View controller still rotates. What is wrong here?