ios - 横向 iOS 9 的初始界面方向

标签 ios iphone orientation ios9 uiinterfaceorientation

Technical Note TN2244: Launching your iPhone Application in Landscape状态:

The values of the UISupportedInterfaceOrientations key determine how the status bar is positioned while the the app is launching. In iOS 7 and below, if the UIInterfaceOrientationPortrait value is present, the status bar will always be positioned for portrait orientation. Otherwise, the status bar will be positioned according to the first orientation that appears under the UISupportedInterfaceOrientations key.

因此在 iOS 8 中,将 UIInterfaceOrientationLandscape 放在 UISupportedInterfaceOrientations 列表的第一位是非常好的,这样您的应用程序就可以在 Landscape 中启动。

它在 iOS 9 中不再起作用。在列表中的任何位置具有 UIInterfaceOrientationPortrait 会强制应用以纵向模式启动。

问题

是否有已知的解决方法?我需要我的应用以横向模式启动。

注意:使用 viewControllers 的 supportedInterfaceOrientations() 方法不是一个选项,因为它在 LaunchScreen 显示后生效。

最佳答案

Having UIInterfaceOrientationPortrait in the list at any position forces app to start in Portrait.

这是绝对正确的——非常好的侦探工作。我做了很多实验才弄明白这一点!这无疑是 iOS 8 的巨大变化。您已经很好地总结了情况。

幸运的是,解决方法很简单。在您的 Info.plist 中,仅包含两个横向方向。现在应用程序将启动到第一个。

现在在应用程序委托(delegate)中实现 application:supportedInterfaceOrientationsForWindow: 以返回 All。这样,当需要显示纵向 View Controller 时,这样做是合法的。

换句话说,将 Info.plist 视为正在启动 的应用程序需要知道的内容,并将 application:supportedInterfaceOrientationsForWindow: 视为什么正在运行的应用需要知道。

关于ios - 横向 iOS 9 的初始界面方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33283365/

相关文章:

ios - 如何在 swift 中将字符索引从布局管理器转换为字符串比例

iPhone SDK Facebook DemoApp 无法启动

ios - 当我调用 api 时,我使用以下方法请给出解决方案,我通过 COCOAPOD 安装 Afnetwoking

Android:HTC EVO 上的相机预览方向(Android 2.1 或 2.2)

ios - 自定义键盘显示在 iOS 11 中的错误位置

ios - 基于 GCM 的服务器和 Firebase 客户端 (iOS) 可以工作吗?

php - 从 iOS 使用 POST 将数组传递给 PHP

iphone - 地幔 :cannot find protocol declaration, 'MTLJSONSerializing'

iphone - UINavigationController 方向更改中的 ViewController

Flutter 设备方向