ios 8中的UIWindow框架与Landscape中的ios 7不同 [英] UIWindow frame in ios 8 different from ios 7 in Landscape

查看:101
本文介绍了ios 8中的UIWindow框架与Landscape中的ios 7不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've create simple module where I add subview to UIWindow. In simulator ios 7(Xcode 5.1.1) I have printed self.windows and I get:

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

但是在ios8(Xcode 6 beta 6)上我得到:

but on ios8 (Xcode 6 beta 6) I get:

<UIWindow: 0x794320d0; frame = (0 0; 1024 768); gestureRecognizers = <NSArray: 0x79437a80>; layer = <UIWindowLayer: 0x7943c400>>

问题是:为什么帧属性有差异?

The question is: why there is a difference in frame property?

推荐答案

可能在你的AppDelegate中你正在初始化你的UIWindow

Probably in your AppDelegate you initializing your UIWindow like this

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

在iOS8之前,UIScreen的bounds属性返回了物理屏幕的边界矩形(即肖像) ),但是当设备旋转时从iOS8边界开始更改文档。

Prior to iOS8 the bounds property of UIScreen returned the bounding rectangle of the physical screen (that is, portrait), but starting from iOS8 bounds changes when the device rotates documentation.

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

You can now use nativeBounds instead if you'd like to get the bounding rectangle of the physical screen.

注意:nativeBounds以像素为单位返回屏幕,但是边界以磅为单位返回。

Note: nativeBounds returns the screen in pixels but bounds returns it in points.

这篇关于ios 8中的UIWindow框架与Landscape中的ios 7不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆