[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查看会话214以获取更多信息:在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 bounds] now interface-oriented
- [UIScreen applicationFrame] now interface-oriented
- Status bar frame notifications are interface-oriented
- Keyboard frame notifications are interface-oriented
这篇关于[UIScreen mainScreen] .bounds.size在iOS8中是否依赖于方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文