Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different UIScreen bounds returned by iOS7 and iOS8 [duplicate]

I make application for Deployment target >= 7.1. And i see the "bug"... Application run in only landscape mode!

Code:

CGSize frameSize = [[UIScreen mainScreen] bounds].size;

In iOS 7 (iPhone 4), returned CGSize (width=320, height=480), but must returned 480x320 (Because run application in landscape mode). In iOS 8 (iPhone 4S), returned CGSize (width=480, height=320) - correct result.

The impression that iOS 7 returned frame without check landscape/portrait mode, and return size for portrait mode.

Thank.

like image 517
ZhukV Avatar asked Dec 14 '22 17:12

ZhukV


1 Answers

The behavior changed in iOS 8.

Quoting UIScreen documentation

Prior to iOS 8, a screen’s bounds rectangle always reflected the screen dimensions relative to a portrait-up orientation. Rotating the device to a landscape or upside-down orientation did not change the bounds. In iOS 8 and later, a screen’s bounds property takes the interface orientation of the screen into account. This behavior means that the bounds for a device in a portrait orientation may not be the same as the bounds for the device in a landscape orientation. Apps that rely on the screen dimensions can use the object in the fixedCoordinateSpace property as a fixed point of reference for any calculations they must make.

like image 95
Sulthan Avatar answered Jan 04 '23 05:01

Sulthan