我正在开发的iOS应用程序有一个视图需要锁定在横向方向。到目前为止,使用shouldAutorotate
和supportedInterfaceOrientations
方法实现了这一点,但在运行iOS9 beta5
的iPad 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
方法来显示。