Search code examples
ios5iphone-5

iPhone 5 screen height 480 instead of 568?


I wan't to make an app that is compatible with an iOS version as low as 5.0, but still keep it to stretch to the iPhone 5 size. I figured I made 3 different storyboards: one for iPad, iPhone and iPhone 5. I used

#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )

from this question

It was very strange when it didn't enter this code

if (IS_IPHONE_5 && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)

So, I figured to print the screen size to the console, using this code:

NSLog(@"%f", [UIScreen mainscreen].bounds.size.height);

Oddly, it gave me the output of

480.000000

instead of 568.f like it should be on a 4-inch device.

Things that might be the problem:

  1. I'm using the iPhone simulator, sorry I don't have an iPhone 5
  2. The app is iOS 5 compatible, which might be the problem

Note: I've tried on 4.6, and it still doesn't work


Solution

  • Your app is not iPhone 5 compatible. Hence, when you run the app on the iPhone 5 simulator, the compatibility mode for 3.5-inch screen turns on automatically, and your app doesn't occupy the entire screen.

    Here you can see how to add iPhone 5 compatability to your app.