简体   繁体   English

iOS 7 - 仅在一个视图控制器中限制横向方向

[英]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.

相关问题 一种View Controller iOS的横向 - Landscape orientation for one view controller ios 在 ios 6 上仅在一个视图中启用横向 - enable landscape orientation in only one view on ios 6 强制iOS方向在一个模态视图控制器上横向移动 - Force iOS orientation to landscape on one modal view controller 模态视图控制器强制iOS 6中的横向方向 - Modal View Controller force Landscape orientation in iOS 6 一个横向控制器 - One controller in landscape orientation iPhone iOS 6 UITabBarController仅限于纵向,如何使Modal View Controller支持横向方向 - iPhone iOS 6 UITabBarController Portrait Only, How to have Modal View Controller support Landscape Orientation 仅为一个视图控制器设置方向 iOS 13 Swift - Set Orientation For Only One View Controller iOS 13 Swift iOS7。仅更改一个视图控制器的页面方向 - iOS 7. Change page orientation only for one view controller iOS:如何更改应用程序中仅一个视图控制器的方向? - iOS: How to change Orientation of only one view controller in app? 如果应用程序设备的方向是纵向的,那么如何仅在iOS中为一个视图构建者设置强制横向,Swift 2.3 - if app device orientation is portrait how to set force landscape only for one view constroller in ios, swift 2.3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM