【问题标题】:Initial Interface Orientation to Landscape iOS 9横向 iOS 9 的初始界面方向
【发布时间】:2015-10-22 14:21:59
【问题描述】:

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

UISupportedInterfaceOrientations 键的值决定了应用启动时状态栏的位置。在 iOS 7 及更低版本中,如果 UIInterfaceOrientationPortrait 值存在,状态栏将始终定位为纵向。否则,状态栏将根据 UISupportedInterfaceOrientations 键下出现的第一个方向定位。

因此,在 iOS 8 中,将 UIInterfaceOrientationLandscape 放在 UISupportedInterfaceOrientations 列表中的首位让您的应用程序以横向启动是非常好的。

它在 iOS 9 中不再起作用。在 any 位置的列表中包含 UIInterfaceOrientationPortrait 会强制应用以纵向启动。

问题

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

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

【问题讨论】:

    标签: ios iphone orientation ios9 uiinterfaceorientation


    【解决方案1】:

    在列表中的任何位置都有 UIInterfaceOrientationPortrait 会强制应用以纵向启动。

    这是绝对正确的——非常好的侦探工作。我花了很多时间来解决这个问题!这与 iOS 8 相比无疑是一个巨大的变化。您对情况的总结非常好。

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

    现在在应用委托中实现application:supportedInterfaceOrientationsForWindow: 以返回全部。这样一来,当需要显示纵向视图控制器时,这样做是合法的。

    换句话说,将 Info.plist 视为 launching 应用程序需要知道的内容,将 application:supportedInterfaceOrientationsForWindow: 视为 running 应用需要知道。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-16
      • 1970-01-01
      • 1970-01-01
      • 2015-12-23
      • 2011-08-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多