关闭旋转?
Turn off rotation?
试图关闭该用户无法更改方向..
我的观点是横向的,它必须是横向的,所以我这样做了
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
and supportedInterfaceOrientations
是property
而不是method
,所以你需要这样添加。
override var shouldAutorotate: Bool {
return false
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.landscapeLeft
}
试图关闭该用户无法更改方向..
我的观点是横向的,它必须是横向的,所以我这样做了
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
and supportedInterfaceOrientations
是property
而不是method
,所以你需要这样添加。
override var shouldAutorotate: Bool {
return false
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.landscapeLeft
}