Joo Park
Joo Park

Reputation: 3145

UIScreen bounds versus applicationFrame

Why do I see in some sample code from Apple (such as PhotoScroller) that I should do the following in loadView:

CGRect frame = [[UIScreen mainScreen] bounds]; 

instead of

CGRect frame = [[UIScreen mainScreen] applicationFrame]; 

Does it make a difference to get the main screen's frame?

Upvotes: 12

Views: 6447

Answers (2)

Code
Code

Reputation: 6251

iOS 9 Update

When using the Split View feature on the iPad, applicationFrame returns the size of your app window. bounds always returns the size of the device.

Upvotes: 2

jamone
jamone

Reputation: 17421

ApplicationFrame is the screen size minus the size of the status bar (if visible), bounds is the screen size regardless of status bar.

So applicationFrame would return CGRectMake(0,0,320,460) assuming your app has the status bar set to be visible, while bounds would return CGRectMake(0,0,320,480) under the same conditions. Those numbers are assuming iPhone/iPod Touch screen sizes.

UIScreen Class Reference

Upvotes: 17

Related Questions