[英]How do I get my iPhone app to start in Landscape mode?
My app is fixed to landscape mode, yet during viewDidLoad() and even viewWillAppear(), the following portrait dimensions still return: 我的应用程序已修复为横向模式,但在viewDidLoad()甚至viewWillAppear()期间,以下纵向尺寸仍会返回:
self.view.bounds.size.width = 320.00
self.view.bounds.size.height = 480.00
It's not until viewDidAppear() that the actual landscape dimensions result. 直到viewDidAppear()才产生实际的景观尺寸。
self.view.bounds.size.width = 480.00
self.view.bounds.size.height = 320.00
I find this weird. 我发现这很奇怪。 Why does this happen!?
为什么会这样?!? and how can I fix this?
我该如何解决这个问题?
In your app's info.plist file, specify the key: 在应用程序的info.plist文件中,指定密钥:
UISupportedInterfaceOrientations
with values for landscape left and right: 左,右景观值:
EDIT : 编辑 :
The raw plist code should look like this: 原始plist代码应如下所示:
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
Edit 2 编辑2
You also need this key which determines the initial orientation of the status bar: 您还需要此键来确定状态栏的初始方向:
<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationLandscapeRight</string>
Further, you need to make sure that ALL of your view controllers (tabbar, navbar, regular view-controllers) implement 此外,您需要确保所有视图控制器(标签栏,导航栏,常规视图控制器)实现
shouldAutorotateToInterfaceOrientation
and return a Landscape (left or right) value. 并返回风景(左或右)值。
Here is an Apple docs article on the subject: 这是有关该主题的Apple文档文章:
Technical Note TN2244 技术说明TN2244
And finally, here are some other SO posts on this topic: post 1 and post 2. 最后,这是有关此主题的其他一些SO帖子: 帖子1和帖子2。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.