[英]iOS 7 - Restrict landscape orientation only in one view controller
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.
所以我在plist文件中添加了两个方向。
-(BOOL) shouldAutorotate {
//Never called
}
- (NSUInteger) supportedInterfaceOrientations {
//Never called
}
can any one tell me how to restrict 任何人都可以告诉我如何限制
Fixed it simply by creating UINavigationController class and overriding 通过创建UINavigationController类和重写来修复它
-(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. 在根窗口中使用此自定义导航控制器类,这就是全部。
This will lock your View Controller's Orientation in Portrait Mode: 这将锁定View Controller在纵向模式下的方向:
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.