-1

I want to port a fully functional app already released in the app store to ios 6.0 and iPhone 5 to avoid those black sandbox boxes.

I have added the Default-568h@2x.png image to enable iphone 5 resolution support and the black boxes don't show in the simulator anymore.

But when I check the resolution of the screen ([UIScreen mainScreen]) to detect an iPhone 5 I always get the resolution 320x568. What am I doing wrong?

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
user1567896
  • 2,398
  • 2
  • 26
  • 43
  • 320x568 (Width x Height) is correct note the Default-`568h`@2x.png there is 568 in it indicating that it is iPhone 5 height. http://stackoverflow.com/questions/13399075/screen-size-of-iphone-5/13399220#13399220 – Popeye Jan 03 '13 at 15:11
  • Also if you update your apps to iOS 6 they may not run on anything below that. You should just update for iPhone 5 and not iOS6 yet. – Popeye Jan 03 '13 at 15:14

1 Answers1

2

in iPhone App How to detect the screen resolution of the device

Jman012's answer to your question:

CGRect screenBounds = [[UIScreen mainScreen] bounds];

That will give you the entire screen's resolution in points, so it would most typically be 320x480 for iPhones. Even though the iPhone4 has a much larger screen size iOS still gives back 320x480 instead of 640x960. This is mostly because of older applications breaking.

CGFloat screenScale = [[UIScreen mainScreen] scale];

This will give you the scale of the screen. For all iPhones and iPodTouches that do NOT have Retina Displays will return a 1.0f, while Retina Display devices will give a 2.0f. Now if you want to get the pixel width & height of the iOS device screen you just need to do one simple thing.

CGSize screenSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);

By multiplying by the screen's scale you get the actual pixel resolution. The usefulness of this code is that it will work in later products by Apple, such as if the iPad ever gets a Retina Display then using the scale will always get you the real pixel resolution.

http://developer.apple.com/library/ios/#documentation/2DDrawing/Conceptual/DrawingPrintingiOS/GraphicsDrawingOverview/GraphicsDrawingOverview.html#//apple_ref/doc/uid/TP40010156-CH14-SW7

Community
  • 1
  • 1
SpaceDust__
  • 4,844
  • 4
  • 43
  • 82