
-
如果根视图是tabbarController设置,否则不设置
123456- (BOOL)shouldAutorotate {return [self.selectedViewController shouldAutorotate];}- (NSUInteger)supportedInterfaceOrientations {return [self.selectedViewController supportedInterfaceOrientations];} -
子类化UINavigationController,假设为BaseNavigationController
-
在BaseNavigationController设置如下方法
- (BOOL)shouldAutorotate { return self.topViewController.shouldAutorotate; } -(UIInterfaceOrientationMask)supportedInterfaceOrientations { return self.topViewController.supportedInterfaceOrientations; } -
随后添加自己的view controller,如果想禁止某个view controller的旋屏:(支持全部版本的控制)
- (BOOL)shouldAutorotate { return YES; } - (UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAllButUpsideDown; }




近期评论