UIScreen 边界与 applicationFrame
为什么我在 Apple 的一些示例代码(例如 PhotoScroller)中看到我应该在 loadView
: 中执行以下操作,
CGRect frame = [[UIScreen mainScreen] bounds];
而不是
CGRect frame = [[UIScreen mainScreen] applicationFrame];
获取主屏幕的框架是否有区别?
Why do I see in some sample code from Apple (such as PhotoScroller) that I should do the following in loadView
:
CGRect frame = [[UIScreen mainScreen] bounds];
instead of
CGRect frame = [[UIScreen mainScreen] applicationFrame];
Does it make a difference to get the main screen's frame?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ApplicationFrame 是屏幕尺寸减去状态栏的尺寸(如果可见),bounds 是屏幕尺寸,与状态栏无关。
因此,假设您的应用将状态栏设置为可见,applicationFrame 将返回 CGRectMake(0,0,320,460),而在相同条件下,bounds 将返回 CGRectMake(0,0,320,480) 。这些数字假定 iPhone/iPod Touch 屏幕尺寸。
UIScreen 类参考
ApplicationFrame is the screen size minus the size of the status bar (if visible), bounds is the screen size regardless of status bar.
So applicationFrame would return
CGRectMake(0,0,320,460)
assuming your app has the status bar set to be visible, while bounds would returnCGRectMake(0,0,320,480)
under the same conditions. Those numbers are assuming iPhone/iPod Touch screen sizes.UIScreen Class Reference
iOS 9 更新
在 iPad 上使用分割视图功能时,
applicationFrame
返回应用程序窗口的大小。bounds
始终返回设备的大小。iOS 9 Update
When using the Split View feature on the iPad,
applicationFrame
returns the size of your app window.bounds
always returns the size of the device.