如何在 viewWillAppear 时强制改变方向?
我只想要一个 navigationController 强制横向,其他 Controller 我想要纵向。
当我按下横向 Controller 时,它显示为纵向,但当我旋转手机时,它会锁定,如我想要的横向。
当 vieWillAppear 时,我该怎么做?有什么作用吗?
最佳答案
override func viewDidLoad() {
super.viewDidLoad()
let value = UIInterfaceOrientation.landscape.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .landscape
}
override var shouldAutorotate: Bool {
return true
}
关于ios - 强制更改 UINavigationController 方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51679325/