[UIScreen mainScreen].bounds.size 在 iOS8 中是否变得依赖于方向? [英] Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8?
本文介绍了[UIScreen mainScreen].bounds.size 在 iOS8 中是否变得依赖于方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 iOS 7 和 iOS 8 中运行了以下代码:
I ran the following code in both iOS 7 and iOS 8:
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
BOOL landscape = (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight);
NSLog(@"Currently landscape: %@, width: %.2f, height: %.2f",
(landscape ? @"Yes" : @"No"),
[[UIScreen mainScreen] bounds].size.width,
[[UIScreen mainScreen] bounds].size.height);
以下是来自 iOS 8 的结果:
The following is the result from iOS 8:
Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 568.00, height: 320.00
与 iOS 7 中的结果相比:
Comparing to the result in iOS 7:
Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 320.00, height: 568.00
是否有任何文档指定了此更改?还是 iOS 8 API 中的临时错误?
Is there any documentation specifying this change? Or is it a temporary bug in iOS 8 APIs?
推荐答案
是的,它在 iOS8 中依赖于方向,而不是错误.您可以查看 WWDC 2014 中的 session 214 以获取更多信息:"View Controller Advancements in iOS 8"
Yes, it's orientation-dependent in iOS8, not a bug. You could review session 214 from WWDC 2014 for more info: "View Controller Advancements in iOS 8"
引自演示文稿:
UIScreen 现在面向界面:
UIScreen is now interface oriented:
- [UIScreen bounds] 现在面向界面
- [UIScreen applicationFrame] 现在面向界面
- 状态栏框架通知面向界面
- 键盘框架通知是面向界面的
这篇关于[UIScreen mainScreen].bounds.size 在 iOS8 中是否变得依赖于方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文