UIScreen applicationFrame 在横向应用程序启动时返回不正确的矩形 (iPhone/iPad) [英] UIScreen applicationFrame returning incorrect rectangle on landscape application launch (iPhone/iPad)
问题描述
在横向模式下启动 iPad 应用程序时无法获得正确的边界.我在 Info.plist 文件中设置了正确的键,并且我的视图控制器在横向(和纵向、natch)中正确启动.
Having trouble getting the correct bounds for my iPad application when launching it in landscape mode. I have the proper keys set in my Info.plist file, and my view controllers launch properly in landscape (and portrait, natch).
在我的 applicationDidFinishLaunching:
方法中,我在 3 秒延迟后调用选择器,该方法调用 [[UIScreen mainScreen] applicationFrame]
,但是它返回给我一个肖像框架(即高度 > 宽度).
In my applicationDidFinishLaunching:
method I'm calling a selector after a 3 second delay, and that method makes a call to [[UIScreen mainScreen] applicationFrame]
, but it's returning me a portrait frame (ie height > width).
有谁知道如何解决这个问题?对我来说,它闻起来像是一个错误(如果是这样,我会提交雷达),但如果它是预期行为,它在哪里记录?
Does anyone know how to fix this? It smells like a bug to me (if so I'll file a radar), but if it's intended behaviour, where is it documented?
推荐答案
当您以横向方式拿着 iPad 并启动应用程序时,视图控制器最初会看到纵向视图的边界(即使方向报告横向).然后,视图控制器将在它出现之前收到一条消息以旋转到横向.
When you are holding the iPad in landscape orientation and launch an app, the view controller initially sees bounds for a portrait view (even though orientation reports landscape). The view controller will then get a message to rotate to landscape orientation before it appears.
这篇关于UIScreen applicationFrame 在横向应用程序启动时返回不正确的矩形 (iPhone/iPad)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!