无法在iPad Air 2上锁定方向

ack*_*n91 15 objective-c orientation ipad ios ios9

我正在处理的iOS应用程序有一个需要以横向方向锁定的视图.到目前为止,这是通过使用shouldAutorotatesupportedInterfaceOrientations方法完成的,但在iPad Air 2运行时iOS9 beta5,这些方法永远不会触发,方向也不会被锁定.

我尝试了以下设备,除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;
}
Run Code Online (Sandbox Code Playgroud)

通过显示视图控制器 presentViewController

ack*_*n91 23

多任务可以通过添加关闭UIRequiresFullScreen字段添加到应用程序与布尔值的info.plist YES,这将允许定向委托方法shouldAutorotate,preferredInterfaceOrientationsupportedInterfaceOrientations射击.

至于锁定方向支持多任务处理,我还没有找到办法做到这一点.


myl*_*gon 5

可以从目标设​​置的"常规"启用"需要全屏"设置.

需要全屏

启用此功能后,现在将运行方向代码.如ackerman91所述,您还可以UIRequiresFullScreen在应用程序info.plist或目标"Info"选项卡中将boolean 设置为YES.