我们的客户指定设备唯一可用的方向应该是纵向模式。在应用程序中设置它很容易,但我正在开发一个框架。这就是为什么我将以下代码添加到我们框架中可用的每个 ViewController 的原因:
override open var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.portrait
}
override open var shouldAutorotate: Bool {
return false
}
override open var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
return UIApplication.shared.statusBarOrientation
}
问题是它不适用于 iPad... 它适用于所有 iphone,但不适用于 iPad。也许有人知道如何通过特定的实现所需的行为 View Controller ?
最佳答案
问题是 iPad 应用程序的默认项目级设置是需要全屏(在应用程序目标 -> 常规中)未被选中。这意味着您的代码甚至没有被查阅。仅当使用您的框架的每个应用程序都选中该复选框时,您正在做的事情才会起作用。
关于ios - 作为框架开发人员,为什么我不能强制 iPad 上的 UIViewController 方向为纵向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54773939/