How to enable landscape mode in a single ViewController in
NavigationController hierarchy
I have 3 UIViewControllers in UINavigationController hierarchy.
How do I enable landscape mode only for the last one of them? (or block
landscape in 1st and 2nd).
(I open each of them by pushing 1st > 2nd > 3rd )
I tried overriding UINavigationController with those methods:
-(NSUInteger)supportedInterfaceOrientations {
UIViewController *top = self.topViewController;
if ([top isMemberOfClass:[PictureViewController class]]) {
return UIInterfaceOrientationPortrait |
UIInterfaceOrientationLandscapeLeft |
UIInterfaceOrientationLandscapeRight;
} else {
return UIInterfaceOrientationPortrait;
}
}
-(BOOL)shouldAutorotate {
UIViewController *top = (UIViewController*) self.topViewController;
if ([top isMemberOfClass:[PictureViewController class]]) {
return YES;
} else {
return NO;
}
}
PictureViewController is 3rd UIViewController. shouldAutorotate returns
YES for it and supportedInterfaceOrientations returns
UIInterfaceOrientationPortrait | UIInterfaceOrientationLandscapeLeft |
UIInterfaceOrientationLandscapeRight;
but landscape is not enabled.
No comments:
Post a Comment