【发布时间】:2017-03-07 13:24:55
【问题描述】:
对于我的项目,设备方向是portrair。但仅适用于view did load 时的一个视图控制器,没有rotating 电话,我想像“向左”一样旋转视图。我试过以下。在我看来确实加载了,
override func viewDidLoad() {
super.viewDidLoad()
let value = UIInterfaceOrientation.LandscapeLeft.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")
}
我用了这个方法……
override func shouldAutorotate() -> Bool {
return true
}
但什么也没发生。然后我也使用下面的方法和上面的方法。
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.All
}
然后它会导致崩溃。没有什么对我有用。任何想法如何做到这一点。
这是我的项目设备方向设置看起来像...
我该怎么做。希望您对此有所帮助。
【问题讨论】:
-
在
AppDelegate中尝试func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask然后检查您的控制器是否可见
标签: ios swift uiinterfaceorientation