繁体   English   中英

如何让我的iPhone应用程序以横向模式启动?

[英]How do I get my iPhone app to start in Landscape mode?

我的应用程序已修复为横向模式,但在viewDidLoad()甚至viewWillAppear()期间,以下纵向尺寸仍会返回:

self.view.bounds.size.width = 320.00
self.view.bounds.size.height = 480.00

直到viewDidAppear()才产生实际的景观尺寸。

self.view.bounds.size.width = 480.00
self.view.bounds.size.height = 320.00

我发现这很奇怪。 为什么会这样?!? 我该如何解决这个问题?

在应用程序的info.plist文件中,指定密钥:

 UISupportedInterfaceOrientations

左,右景观值:

在此输入图像描述

编辑

原始plist代码应如下所示:

    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>

编辑2

您还需要此键来确定状态栏的初始方向:

 <key>UIInterfaceOrientation</key>
 <string>UIInterfaceOrientationLandscapeRight</string>

此外,您需要确保所有视图控制器(标签栏,导航栏,常规视图控制器)实现

 shouldAutorotateToInterfaceOrientation

并返回风景(左或右)值。

这是有关该主题的Apple文档文章:

技术说明TN2244

最后,这是有关此主题的其他一些SO帖子: 帖子1帖子2。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM