试图关闭该用户无法改变方向..
我的观点是横向的,它必须是横向的,所以我是这样做的
let value = UIInterfaceOrientation.landscapeLeft.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
此外,用户无法更改旋转
private func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.landscapeLeft
}
private func shouldAutorotate() -> Bool {
return false
}
问题是它不工作。我在插入景观之后,但我仍然可以旋转它。
最佳答案
来自 swift 3 shouldAutorotate
和 supportedInterfaceOrientations
是property
而不是method
,所以你需要这样添加。
override var shouldAutorotate: Bool {
return false
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.landscapeLeft
}
关于ios - 关闭旋转?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41806016/