4

我正在使用情节提要,并且在 UITabBarController 中嵌入了 UINavigationController。我推送一个视图控制器,然后从这个视图控制器我呈现一个带有 UIViewController 的 MODAL UINavigationController。

问题是,当我在模态视图之前的所有视图都不能旋转时,模态视图控制器可以旋转。如何停止允许任何旋转的模态导航控制器?

我试过添加:

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

谢谢

4

1 回答 1

5

尝试分类 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];
}
于 2012-11-11T19:09:58.097 回答