【发布时间】:2015-06-21 17:48:26
【问题描述】:
我知道这个问题已经在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;
}
但无法在横向模式下旋转它。
【问题讨论】:
标签: ios xcode swift orientation uiinterfaceorientation