【问题标题】:How to change the orientation of the iDevice (iPad/iPhone)?如何更改 iDevice (iPad/iPhone) 的方向?
【发布时间】:2013-05-27 08:18:06
【问题描述】:

通过以下操作可以轻松更改 iPad/iPhone 模拟器的方向:硬件->向左或向右旋转。 但是,如何在 iDevice(iPad 设备或 iPhone 设备?)上更改它?

有人可以帮帮我吗?

我应该添加一些代码吗?

【问题讨论】:

  • 您能解释一下您的问题吗?据我了解,如果您想更改真实设备的方向,我想您必须用手旋转设备。 :D
  • 看,我在 iPad 设备上运行我的应用程序,它显示为横向模式,但我希望它以纵向模式显示。

标签: iphone ios ios-simulator uiinterfaceorientation uidevice


【解决方案1】:

转到您的摘要选项卡,向下滚动以转到“iPad 部署信息”。 取消选择“支持的界面方向”中的所有四个选项。 然后再次选择,但先选择人像,然后再选择。

在您期望处于纵向模式的视图中,只需添加

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
    return (orientation == UIInterfaceOrientationMaskAll);
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

希望这会有所帮助。

【讨论】:

    【解决方案2】:

    转到支持文件中的 .plist 文件

    在那里你会看到支持的界面方向 添加以下键

    Item 0 String Portrait (top home button)
    Item 1 String Portrait (bottom home button)
    Item 2 String Landscape (left home button)
    Item 3 String Landscape (right home button)
    

    【讨论】:

      【解决方案3】:

      对 UIApplication 的 setStatusBarOrientation 的调用将伪造旋转

      【讨论】:

        【解决方案4】:

        Initial interface orientation 键/值添加到您的$appName-info.plist 文件中

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-12-28
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多