为什么[UIScreen mainScreen] .bounds]没有返回全屏尺寸? [英] Why [UIScreen mainScreen].bounds] is not returning full screen size?
问题描述
我有一个在新的iPhone 5视网膜宽屏设备之前创建的应用程序。
现在我正在尝试支持这个高清宽屏。
I have an app that was created prior to the new iPhone 5 retina widescreen device. Now i am trying to support this high definition widescreen.
我调整主ViewController和主窗口XIB文件,以便将它们设置为Autolayout。我可以验证通过IB显示的宽度/高度显示320 x 568。
I adjust the main ViewController and the main window XIB files so that they are set to Autolayout. I can verify that the width/height displayed via the IB shows 320 x 568.
然而,当我在模拟器中运行时,我可以看到高度仍然是480。
用于打印高度(和宽度)的代码位于主视图控制器的viewWillAppear方法中:
However, when I run in simulator, i can see that the height is still 480. The code im using to print the height (and width) is in the main view controller's viewWillAppear method:
[UIScreen mainScreen].bounds]
为什么size.height仍然是480而不是568?
Why is the size.height still 480 instead of 568?
推荐答案
您必须添加iPhone 5启动图像( Default-568h@2x.png
)你的项目。
You have to add the iPhone 5 Launch image (Default-568h@2x.png
) to your project.
568点高的启动图像告诉iOS以4模式启动您的应用程序。如果您没有此图像,您的应用程序将被视为3.5应用程序。即使它是4兼容。
The 568 point tall launch image tells iOS to launch your app in 4" mode. If you don't have this image, your app is treated as a 3.5" app. Even if it is 4" compatible.
这篇关于为什么[UIScreen mainScreen] .bounds]没有返回全屏尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!