如何解决在 iPad 上强制 UISplitViewController 方向为横向
我正在努力让我的 UISplitViewController 始终保持横向模式。与其他 ViewController 一起使用的方法在这里似乎不起作用。
在我的 AppDelegate 中,我有:
var supportedInterfaceOrientation: UIInterfaceOrientationMask = .all
func application(_ application: UIApplication,supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return supportedInterfaceOrientation
}
在我的 UISplitViewController 中,我有:
let appDelegate = UIApplication.shared.delegate as! AppDelegate
override func viewDidLoad() {
super.viewDidLoad()
appDelegate.supportedInterfaceOrientation = .landscapeLeft
UIDevice.current.setValue(UIInterfaceOrientation.landscapeLeft.rawValue,forKey: "orientation")
}
deinit {
appDelegate.supportedInterfaceOrientation = .all
}
override var shouldAutorotate: Bool {
return false
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .landscapeLeft
}
override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
return .landscapeLeft
}
我正在像这样展示我的 UISplitViewController:
let vc = self.storyBoard.instantiateViewController(withIdentifier: "CompareSplitVC") as! CompareSplitViewController
vc.modalPresentationStyle = .fullScreen
self.present(vc,animated: true,completion: {})
所有这些都没有效果,其中一个被调用:shouldAutorotate、supportedInterfaceOrientations、preferredInterfaceOrientationForPresentation
我做错了什么?
编辑: 我在 iPad 上遇到了这个问题,但在 iPhone 上没有。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。