我正在努力在横向模式下锁定我的应用程序.我只有一个ViewController,它不在NavigationController中.在视图控制器内部,我有以下代码:
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.LandscapeLeft
}
override func shouldAutorotate() -> Bool {
return false;
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return UIInterfaceOrientation.LandscapeLeft
}
Run Code Online (Sandbox Code Playgroud)
在设置的"常规"选项卡中,我有以下内容:
在ViewController的属性中我有这个:
我尝试在ViewDidLoad中使用UIDevice.currentDevice().setValue(...),但这没有任何效果.我试图在iPad mini上运行这个应用程序,我完全不知所措.任何帮助将非常感激.
更新:我终于找到了答案.在"Supporting Files"文件夹中,info.plist文件具有"Supported Interface Orientations"和"Supported Interface Orientations(iPad)"的属性.
显然,由于我在iPad上运行应用程序,因此覆盖了我的所有其他选择和代码.删除不需要的方向解决了我的问题.希望这有助于某人!
| 归档时间: |
|
| 查看次数: |
1938 次 |
| 最近记录: |