我正在使用 Swift4 使用 Xcode9 开发一个应用程序,它最初是为 iPad 设计的,但现在也需要在手机上运行。我需要将手机锁定为纵向,iPad 保持纵向/横向。
在使用 shouldautorotate 函数并根据设备返回 true 或 false 之前,我已经完成了此操作,如下所示。
override func shouldAutorotate() -> Bool {
return false
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.all
}
但是,当我更改方向时,它不会触发。这是另一种折旧的方法吗?如果是,我现在如何限制方向?