我正在使用故事板,我在UITabBarController中嵌入了UINavigationController.
我推出一个视图控制器然后从这个视图控制器我提出了一个带UIViewController的MODAL UINavigationController.
我推出一个视图控制器然后从这个视图控制器我提出了一个带UIViewController的MODAL UINavigationController.
问题是,当模态视图之前的所有视图都不能时,模态视图控制器可以旋转.
如何停止Modal导航控制器允许任何旋转?
我试过添加:
-(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; }
和
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); }
谢谢
解决方法
尝试分类UINavigationController
@implementation UINavigationController (Rotation_IOS6) -(BOOL)shouldAutorotate { return [[self.viewControllers lastObject] shouldAutorotate]; } -(NSUInteger)supportedInterfaceOrientations { return [[self.viewControllers lastObject] supportedInterfaceOrientations]; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation]; }