ios7 - ios 8 中的 UIWindow 框架与 Landscape 中的 ios 7 不同

标签 ios7 ios8 xcode6 uiinterfaceorientation uiwindow

我创建了简单的模块,在其中将 subview 添加到 UIWindow。在模拟器 ios 7(Xcode 5.1.1)中,我打印了 self.windows 并得到:

<UIWindow: 0x8db1670; frame = (0 0; 768 1024); autoresize = W+H; gestureRecognizers = <NSArray: 0x8db1a70>; layer = <UIWindowLayer: 0x8db17d0>>

但在 ios8 (Xcode 6 beta 6) 上我得到:
<UIWindow: 0x794320d0; frame = (0 0; 1024 768); gestureRecognizers = <NSArray: 0x79437a80>; layer = <UIWindowLayer: 0x7943c400>>

问题是:为什么框架属性会有所不同?

最佳答案

可能在您的 AppDelegate 中,您像这样初始化 UIWindow

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

在 iOS8 之前,UIScreen 的 bounds 属性返回物理屏幕的边界矩形(即竖屏),但从 iOS8 开始,设备旋转时边界会发生变化documentation.

如果您想获得物理屏幕的边界矩形,现在可以使用 nativeBounds 代替。

注意:nativeBounds 以像素为单位返回屏幕,但 bounds 以点为单位返回。

关于ios7 - ios 8 中的 UIWindow 框架与 Landscape 中的 ios 7 不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25741743/

相关文章:

ios - 如何计算 iOS 7 中的实际字体磅值(不是边界矩形)?

ios - 显示排行榜会导致应用崩溃,因为不支持 showViewController

ios - 从结构模型填充 View 时的 nil 值

ios - xcode 项目中的应用程序没有改变

ios - 无法确定要启动的模拟器设备。 - Xcode

ios - 使用swift在六边形中裁剪方形图像

ios7 - SWTableViewCell 一次显示一个菜单

ios - CABasicAnimation 不适用于 64 位设备

ios - 如何从模态视图 Controller 传递参数?

json - NSJSONSeralization.dataWithJSONObject 崩溃