我知道这个问题已经在
here,here和
here中提出过.我尝试了所有可能的方法,但没有成功.
我正在尝试在Swift(iOS 8)中开发一个应用程序,其中只有一个视图控制器可以在所有方向上查看,其他只在纵向中查看.
为此,我在Target-> General-> Device Orientation中仅启用了Portrait模式(因为我希望应用程序仅在纵向模式下运行,但一个视图控制器除外).
override func supportedInterfaceOrientations() -> Int { return Int(UIInterfaceOrientationMask.All.rawValue) } override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation { return UIInterfaceOrientation.LandscapeLeft; } override func shouldAutorotate() -> Bool { return true; }
但无法在横向模式下旋转它.
解决方法
请执行下列操作:
>在“常规信息”屏幕中启用所需的方向
>在每个ViewController中,使用true或false覆盖autorotation函数
(对于应旋转的那个是真的,对其他人是假的):
override var shouldAutorotate: Bool { return true }
希望有帮助:)