无法在 iPad Air 2 上锁定方向
Unable to lock orientation on iPad Air 2
我正在处理的 iOS 应用程序有一个视图需要锁定为横向。到目前为止,这是通过使用 shouldAutorotate
和 supportedInterfaceOrientations
方法完成的,但是在 iPad Air 2
运行 iOS9 beta5
上,这些方法永远不会触发并且方向未锁定。
我已经在以下设备上进行了尝试,除 Air2 之外的所有设备都触发了方法(运行 使用 Xcode beta6 进行调试):
iPhone 6+, iPad 迷你, iPad 空气 2, iPad 2, iPad 3
不触发的方法如下:
- (BOOL)shouldAutorotate {
return YES;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationMaskLandscapeRight;
}
视图控制器通过presentViewController
显示
我认为这是多任务处理功能的附带损害。
您将无法再假设您拥有整个屏幕。
可能还有其他方法可以调用来禁止多任务模式。
可以通过将 UIRequiresFullScreen
字段添加到具有布尔值 YES
的应用程序 info.plist 来关闭多任务处理,这将允许方向委托方法 shouldAutorotate
, preferredInterfaceOrientation
, 和 supportedInterfaceOrientations
开火。
就锁定方向 AND 支持多任务处理而言,我还没有找到实现此目的的方法。
可以从目标设置的 'General' 中启用 'Requires full screen' 设置。
启用此功能后,方向代码现在将为 运行。如 ackerman91 所述,您还可以在应用程序 info.plist 或目标 'Info' 选项卡中将 UIRequiresFullScreen
布尔值设置为 YES。
我正在处理的 iOS 应用程序有一个视图需要锁定为横向。到目前为止,这是通过使用 shouldAutorotate
和 supportedInterfaceOrientations
方法完成的,但是在 iPad Air 2
运行 iOS9 beta5
上,这些方法永远不会触发并且方向未锁定。
我已经在以下设备上进行了尝试,除 Air2 之外的所有设备都触发了方法(运行 使用 Xcode beta6 进行调试): iPhone 6+, iPad 迷你, iPad 空气 2, iPad 2, iPad 3
不触发的方法如下:
- (BOOL)shouldAutorotate {
return YES;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationMaskLandscapeRight;
}
视图控制器通过presentViewController
我认为这是多任务处理功能的附带损害。 您将无法再假设您拥有整个屏幕。 可能还有其他方法可以调用来禁止多任务模式。
可以通过将 UIRequiresFullScreen
字段添加到具有布尔值 YES
的应用程序 info.plist 来关闭多任务处理,这将允许方向委托方法 shouldAutorotate
, preferredInterfaceOrientation
, 和 supportedInterfaceOrientations
开火。
就锁定方向 AND 支持多任务处理而言,我还没有找到实现此目的的方法。
可以从目标设置的 'General' 中启用 'Requires full screen' 设置。
启用此功能后,方向代码现在将为 运行。如 ackerman91 所述,您还可以在应用程序 info.plist 或目标 'Info' 选项卡中将 UIRequiresFullScreen
布尔值设置为 YES。