iOS 7 - 仅在一个视图控制器中限制横向方向 [英] iOS 7 - Restrict landscape orientation only in one view controller
本文介绍了iOS 7 - 仅在一个视图控制器中限制横向方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只需要在纵向模式下打开第一个视图控制器。由于其余视图控制器将使用两个方向。所以我在plist文件中添加了两个方向。
I need to open the first view controller only in portrait mode. As the rest view controllers will use both orientation. So i have added both orientation in plist file.
-(BOOL) shouldAutorotate {
//Never called
}
- (NSUInteger) supportedInterfaceOrientations {
//Never called
}
任何人都可以告诉我如何限制
can any one tell me how to restrict
推荐答案
通过创建UINavigationController类来修复它覆盖
Fixed it simply by creating UINavigationController class and overriding
-(NSUInteger)supportedInterfaceOrientations
{
AppDelegate *appDelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
if(appDelegate.isOrientationOn) {
return UIInterfaceOrientationMaskAll;
}
return UIInterfaceOrientationMaskPortrait;
}
在根窗口中使用此自定义导航控制器类,这就是全部。
Use this custom navigation controller class in root window and that's all.
这篇关于iOS 7 - 仅在一个视图控制器中限制横向方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文