我在 iOS 7 和 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);
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 中的结果比较:
Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 320.00, height: 568.00
是否有任何文档指定此更改?
答案
是的,它在 iOS8 中依赖于方向,而不是错误。“iOS 8 中的视图控制器改进”
演讲中引用:
UIScreen 现在是面向界面的:
- [UIScreen 边界] 现在面向界面
- [UIScreen applicationFrame] 现在面向界面
- 状态栏框架通知是面向界面的
- 键盘框架通知是面向界面的