gpt4 book ai didi

ios - 在 Swift iOS9 中锁定横向

转载 作者:可可西里 更新时间:2023-11-01 00:13:18 25 4
gpt4 key购买 nike

我正在努力将我的应用程序锁定为横向模式。我只有一个 ViewController,它不在 NavigationController 中。在 View Controller 中,我有以下代码:

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.LandscapeLeft
}
override func shouldAutorotate() -> Bool {
return false;
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return UIInterfaceOrientation.LandscapeLeft
}

在设置的“常规”选项卡中,我有以下内容:

General

在 ViewController 的属性中我有这个:

Attributes

我试过在 ViewDidLoad 中使用 UIDevice.currentDevice().setValue(...),但没有效果。我试图在 iPad mini 上运行这个应用程序,但我完全不知所措。任何帮助将不胜感激。

最佳答案

更新:我终于找到了这个问题的答案。在“Supporting Files”文件夹中,info.plist 文件具有“Supported Interface Orientations”和“Supported Interface Orientations (iPad)”的属性。

enter image description here

显然这覆盖了我所有其他选择和代码,因为我是在 iPad 上运行该应用程序。删除不需要的方向解决了我的问题。希望这对某人有帮助!

关于ios - 在 Swift iOS9 中锁定横向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33200184/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com