无法锁定iPad Air 2的方向

15

我正在开发的iOS应用程序有一个视图需要锁定在横向方向。到目前为止,使用shouldAutorotatesupportedInterfaceOrientations方法实现了这一点,但在运行iOS9 beta5iPad Air 2上,这些方法从未触发,方向也没有被锁定。

我已经在以下设备上尝试过此问题,除Air2外,其他所有设备均能正常运行(使用Xcode beta6进行调试):iPhone 6+、iPad Mini、iPad Air 2、iPad 2、iPad 3。

未触发的方法如下:

- (BOOL)shouldAutorotate {
    return YES;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationMaskLandscapeRight;
}

视图控制器通过presentViewController方法来显示。

3个回答

23

通过在应用程序的info.plist中添加UIRequiresFullScreen字段,并将布尔值设置为YES,可以关闭多任务处理功能,这将允许方向委托方法shouldAutorotatepreferredInterfaceOrientationsupportedInterfaceOrientations启动。

至于锁定方向并且支持多任务处理,我尚未发现一种方法来实现。


5
“需要全屏”设置可以在目标设置的“常规”中启用。

Requires full screen

启用此功能后,方向代码将会运行。正如ackerman91所述,您还可以在应用程序info.plist或目标“信息”选项卡中将UIRequiresFullScreen布尔值设置为YES。


0

我认为这是多任务功能的副作用。

你不能再假设自己拥有整个屏幕了。

可能还有其他方法来禁止多任务模式。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接