【问题标题】:iOS - iPad Air and iPad Pro force device orientation in landscape onlyiOS - iPad Air 和 iPad Pro 仅在横向强制设备方向
【发布时间】:2016-09-14 14:38:40
【问题描述】:

我正在尝试实现 iOS 应用程序特定的视图控制器始终只打开横向模式。我在 viewWillAppear 中添加以下代码。

NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
 [[UIDevice currentDevice] setValue:value forKey:@"orientation"];

上面的代码在 iPhone 4s/5/5s/6/6s 和 iPad 2/Retina 设备上运行良好。但 iPad Air/Air 2/Pro 不工作。如何解决这个问题。请指导我谢谢。

【问题讨论】:

    标签: ios objective-c iphone ipad


    【解决方案1】:

    而不是设备方向在您的 ViewController 中使用以下内容:

    - (UIInterfaceOrientationMask)supportedInterfaceOrientations{
        return UIInterfaceOrientationMaskLandscape;
    }
    

    【讨论】:

    • @jagdish 感谢您的回复.. 我也找到了一些解决方法.. 我启用了纵向并需要在 Target 中使用全屏模式——设备方向.. 然后上面的编码工作正常。 .
    • 好的..所以这不是你想要的..我误解了你的问题吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-06
    • 2012-03-10
    • 2015-01-01
    • 2012-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多