【发布时间】:2016-11-03 06:46:40
【问题描述】:
我正在尝试将我的viewController 锁定为纵向,而不必依赖部署信息,但我的以下代码不起作用
override var shouldAutorotate: Bool {
return false
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.portrait
}
override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
return UIInterfaceOrientation.portrait
}
override func viewDidLoad() {
super.viewDidLoad()
}
【问题讨论】:
-
为什么不依赖这些信息呢?这不是尝试比 xcode 更聪明的好方法
-
我复制并粘贴了您的代码,它确实将 viewController 锁定为 portrait 模式,
override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return UIInterfaceOrientationMask.portrait }应该足以满足您的需求。 -
@Carlo 请看这里:- stackoverflow.com/questions/31758706/…
标签: swift swift3 orientation