Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWindow frame in ios 8 different from ios 7 in Landscape

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?

like image 244
edzio27 Avatar asked Sep 09 '14 09:09

edzio27


1 Answers

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.

like image 114
fdiaz Avatar answered Nov 26 '22 10:11

fdiaz