3

I am testing my application on iPhone 5 and its reporting screen height as 480 on the iPhone 5. In iPhone 5 simulator I get correct height i.e. 568, but the same code is reporting 480 on hardware. I am using following code to get the screen height.

[UIScreen mainScreen].bounds.size.height]

What could be the reason?

Thanks

dev
  • 2,180
  • 2
  • 30
  • 46
  • possible duplicate of [How do I support the taller iPhone 5 screen size?](http://stackoverflow.com/questions/12397811/how-do-i-support-the-taller-iphone-5-screen-size) – Steven Fisher Nov 23 '12 at 03:59
  • Also, could be seen as possible duplicate of http://stackoverflow.com/questions/12543264/screen-height-compatible-in-iphone5-and-iphone4. – Steven Fisher Nov 23 '12 at 04:00
  • Or http://stackoverflow.com/questions/12752738/on-iphone5-uiscreen-mainscreen-bounds-size-comes-back-as-320x480, or http://stackoverflow.com/questions/12395200/how-to-develop-or-migrate-apps-for-iphone-5-screen-resolution, etc, etc. – Steven Fisher Nov 23 '12 at 04:01
  • 1
    @StevenFisher None of the questions you linked address the question of why the correct height is reported in the simulator but not an actual device. – rmaddy Nov 23 '12 at 04:37
  • Just tested: The simulator also returns 480. – Steven Fisher Nov 23 '12 at 18:17
  • 1
    Thinking about this a bit more. Did you try adding a Default-568h@2x.png at some point? The app installed in your simulator may still have it. Xcode does not (to my knowledge, and as of this writing) delete removed files from apps in the simulator's sandboxes. – Steven Fisher Nov 23 '12 at 18:19
  • One other possibility: This could happen ff you botched the case of Default-568h@2x.png. The simulator is not case sensitive, so it would show 568. The device is, so it would show 480. – Steven Fisher Nov 23 '12 at 18:23
  • @StevenFisher, I just found that out. Yes I did add the default image and then removed it for some reason and simulator is able to find it and reports the correct size. Adding the images fixed the issue. – dev Nov 23 '12 at 18:23
  • Awesome. Glad you fixed it. – Steven Fisher Nov 23 '12 at 18:24

4 Answers4

5

Support for the taller screen of the iPhone 5 and 5th gen iPod touch requires the existence of the Default-568h@2x.png launch image. The simulator is case insensitive while a real device is case sensitive for filenames.

Since the simulator is reporting the taller height while the device isn't, perhaps you have the launch image with the wrong filename. Make sure it is really Default-568h@2x.png and not something else like default-568h@2x.png or Default-568h@2x.PNG.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • For some reason when I add the default launch image for 4 inch display the issue got fixed. I think not having a default image for 4 inch aslo makes the iphone think that the application needs to be ran in 3.5inch screen size. – dev Nov 23 '12 at 18:20
  • Yes, disabling 3.5" mode is what the 4" launch image is for. :) – Steven Fisher Nov 23 '12 at 18:22
  • @StevenFisher I'd word that differently. The 4" launch image enables an app to fully support the 4" screen on those type of devices but it doesn't disable 3.5" mode. The app still runs in 3.5" mode on those type of devices. – rmaddy Nov 23 '12 at 18:51
  • True enough. How about: Disabling 3.5" **compatibility** mode **on the iPhone 5**? :) – Steven Fisher Nov 23 '12 at 19:36
1

it seems like your app is running in "centered, letterboxed" mode . To remove this mode and allow resize you better go through this post iPhone 5 letterboxing / screen resize

Community
  • 1
  • 1
Abhishek Chauhan
  • 1,984
  • 16
  • 16
0

You can also try

CGRectGetHeight([UIScreen mainScreen].applicationFrame)
CGRectGetWidth([UIScreen mainScreen].applicationFrame)
krammer
  • 2,598
  • 2
  • 25
  • 46
0

Not have the exact idea about it. I'm using this to get the screen height.

If you are using UINavigationController or UIViewControler get the

self.navigationController.view.frame.size.height
or
self.view.frame.size.height.

basically ur viewController's view's height.

damithH
  • 5,148
  • 2
  • 27
  • 31