本文介绍了Modal UINavigationController - 我无法停止旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用故事板,并且在 UITabBarController 中嵌入了一个 UINavigationController.我推了一个视图控制器,然后从这个视图控制器我呈现了一个带有 UIViewController 的 MODAL UINavigationController.
I am using storyboards and I have a UINavigationController embedded in a UITabBarController.i push a view controller then from this view controller I present a MODAL UINavigationController with a UIViewController.
问题是,当模态视图之前的所有视图都不能旋转时,模态视图控制器可以旋转.如何停止允许任何旋转的模态导航控制器?
The problem is, the modal view controller can rotate when all my view previous to the modal view can't.How do I stop the Modal nav controller allowing any rotation?
我尝试添加:
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
和
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
谢谢
推荐答案
尝试分类 UINavigationController
try to categories 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];
}
这篇关于Modal UINavigationController - 我无法停止旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!