0
为我的项目,设备方向是portrair
。但只有一个视图控制器,当view did load
,没有rotating
电话,我想旋转视图像'风景左'。我尝试了以下。在我看来没有负荷,如果应用程序的设备方向是纵向如何设置强制景观只有一个视图Constroller在ios,swift 2.3
override func viewDidLoad() {
super.viewDidLoad()
let value = UIInterfaceOrientation.LandscapeLeft.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")
}
,我用这个方法...
override func shouldAutorotate() -> Bool {
return true
}
但没有happned。然后我用上面的方法也使用下面的方法。
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.All
}
然后它会导致崩溃。并没有为我工作。任何想法如何做到这一点。
这是我的项目设备方向设置看起来像......
我怎么能做到这一点。希望你对此有所帮助。
请查看http://www.jairobjunior.com/blog/2016/03/05/how-to-rotate-only-one-view-controller-to-landscape-in-ios-slash- swift/ –
尝试'AppDelegate'中的'func application(_ application:UIApplication,supportedInterfaceOrientationsFor window:UIWindow?) - > UIInterfaceOrientationMask',然后检查你的控制器是否可见 – zombie