UIWindow frame in ios 8 different from ios 7 in Landscape

此生再无相见时 提交于 2020-01-02 02:18:28

问题


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?


回答1:


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.




回答2:


My solution for this issue was just to ignore the:

CGAffineTransformMakeRotation

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



来源:https://stackoverflow.com/questions/25741743/uiwindow-frame-in-ios-8-different-from-ios-7-in-landscape

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!