gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 04:43:33 24 4
gpt4 key购买 nike

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/

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