UIWindow frame in ios 8 different from ios 7 in La

2019-04-24 09:18发布

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>>

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?

2条回答
Evening l夕情丶
2楼-- · 2019-04-24 10:09

My solution for this issue was just to ignore the:

CGAffineTransformMakeRotation

on iOS8 and now everything works for me! thanks :)

查看更多
女痞
3楼-- · 2019-04-24 10:21

Probably in your AppDelegate you initializing your UIWindow like this

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

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.

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

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

查看更多
登录 后发表回答