【问题标题】:iOS app starts in landscape modeiOS 应用以横向模式启动
【发布时间】:2012-03-01 22:41:51
【问题描述】:

我有一个奇怪的问题。我的应用程序一直以横向模式启动。如果我在模拟器中打开它,它会自动旋转到横向模式。当我在 iPhone 上启动它时,它首先以横向模式启动,然后在旋转到正确位置后不久。我已将 .plist 中的“初始界面方向”设置为纵向,但没有任何改变。

【问题讨论】:

    标签: objective-c ios orientation screen-orientation device-orientation


    【解决方案1】:

    在 XCode 6.4 中,我只是取消选中所有 4 个设备方向,并在目标应用程序的部署信息中从纵向开始重新选择它们。显然,它们在此处检查的顺序控制了 plist 文件中值的顺序。

    【讨论】:

      【解决方案2】:

      如果只支持横向,写代码

      - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
      {
      return UIInterfaceOrientationIsLandscape(interfaceOrientation);
      }
      

      它对我有用。

      【讨论】:

      • 也许您已经将UIInterfaceOrientation 设置为Supported interface orientation 中的项目0。看起来这与提出的问题不匹配
      【解决方案3】:

      我遇到了同样的问题。如果您转到 Supported Interface Orientations,您会看到 项目 0 ... 第 1 项 ...

      等等。 如果您编辑此列表以使 Portrait(底部主页按钮)成为列表中的第一项,则您的应用将以纵向模式打开。您仍然可以支持其他方向作为项目 1 到 3。

      【讨论】:

      • 谢谢!这很简单,但我已经花了很多时间。
      • 谢谢,这只是解决了我对我的应用程序有点恼火的问题。 :-D
      • 请注意,虽然这是正确的修复,但它是 Apple 的回归。来自文档:此方法是一个替代方法,它通过为 UIInterfaceOrientationPortrait、UIInterfaceOrientationLandscapeLeftUIInterfaceOrientationLandscapeRight 方向返回 YES 来替换 默认行为。跨度>
      • 谢谢!。很长一段时间以来,我一直在努力想象出了什么问题。
      • 这对我在 iOS 8 (iPad Mini) 上不起作用。我所做的是-(BOOL) shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; }。它可以防止您的应用在启动期间进入横向模式。
      【解决方案4】:

      转到您支持的设备方向并检查您是否选择了纵向模式

      【讨论】:

      • 所有模式都选好了(其实我都需要)。
      • 那方法呢 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // 支持的方向返回 YES 返回 YES; }
      猜你喜欢
      • 2012-02-14
      • 1970-01-01
      • 1970-01-01
      • 2013-05-18
      • 2012-03-06
      • 1970-01-01
      • 2015-01-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多