Search code examples
iosobjective-cscreen-resolutioniphone-6iphone-6-plus

Native Resolution Verification for iPhone 6 and iPhone 6+


Trying to run in native resolution in the simulator for iPhone 6 and 6+. I'm using Xcode 6.

Have done the Launch Image installation in XCode at the proper resolutions.

The iPhone 6 (Retina HD 4.7) requires a portrait launch image of 750 x 1334.

The iPhone 6 Plus (Retina HD 5.5) requires both portrait and landscape images sized as 1242 x 2208 and 2208 x 1242 respectively.

But in code,

[[UIScreen mainScreen] bounds].size.width
[[UIScreen mainScreen] bounds].size.height

get

375.000000, 667.000000 for iphone 6 simulator
414.000000, 736.000000 for iphone 6+ simulator

if the images are removed get

 320.000000, 568.000000 for iphone 6 simulator
 320.000000, 568.000000 for iphone 6+ simulator

So I guess the top numbers validate that we are in hi-res mode, but why do we not get the true screen resolution? iphone 6 is /2 and iphone 6+ / 3. Or this is just by design.

[ADDITION]

Thought I would add this script in for an example on how to generate all of the XCODE 6 Launch Screens....

Have to install ImageMagick, use a source file without alpha layer.

convert black.png -resize 1024x768!  Launch-iPad-1024x768-Landscape-ios-5-6-1x.png
convert black.png -resize 1024x768!  Launch-iPad-1024x768-Landscape-ios-7-8-1x.png
convert black.png -resize 1536x2048! Launch-iPad-1536x2048-Portrait-ios-5-6-2x.png
convert black.png -resize 1536x2048! Launch-iPad-1536x2048-Portrait-ios-7-8-2x.png
convert black.png -resize 2048x1536! Launch-iPad-2048x1536-Landscape-ios-5-6-2x.png
convert black.png -resize 2048x1536! Launch-iPad-2048x1536-Landscape-ios-7-8-2x.png
convert black.png -resize 768x1024!  Launch-iPad-768x1024-Portrait-ios-5-6-1x.png
convert black.png -resize 768x1024!  Launch-iPad-768x1024-Portrait-ios-7-8-1x.png
convert black.png -resize 1242x2208! Launch-iPhone-1242x2208-Portrait-ios-8-HD-5.5.png
convert black.png -resize 2208x1242! Launch-iPhone-2208x1242-Landscape-ios-8.png
convert black.png -resize 320x480!   Launch-iPhone-320x480-Portrait-ios-5-6-1x.png
convert black.png -resize 640x1136!  Launch-iPhone-640x1136-Portrait-ios-5-6-Retina-4.png
convert black.png -resize 640x1136!  Launch-iPhone-640x1136-Portrait-ios-7-8-Retina-4.png
convert black.png -resize 640x960!   Launch-iPhone-640x960-Portrait-ios-5-6-2x.png
convert black.png -resize 640x960!   Launch-iPhone-640x960-Portrait-ios-7-8-2x.png
convert black.png -resize 750x1334!  Launch-iPhone-750x1334-Portrait-ios-8-HD-4.7.png

Solution

  • You can use either [UIScreen mainScreen].nativeScale witch will gives you 2.6f if normal, and 2.8f if zoomed on iPhone 6 plus, or the defined macros :

    #define IS_OS_8_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
    #define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    #define IS_IPHONE_5 (IS_IPHONE && ([[UIScreen mainScreen] bounds].size.height == 568.0) && ((IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale == [UIScreen mainScreen].scale) || !IS_OS_8_OR_LATER))
    #define IS_STANDARD_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0  && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale == [UIScreen mainScreen].scale)
    #define IS_ZOOMED_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0 && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale > [UIScreen mainScreen].scale)
    #define IS_STANDARD_IPHONE_6_PLUS (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0)
    #define IS_ZOOMED_IPHONE_6_PLUS (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0 && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale < [UIScreen mainScreen].scale)
    

    Here is the screen bounds for If screen zoom or not

    <UIScreenMode: 0x17802f240; size = 1242.000000 x 2208.000000> // STANDARD
    <UIScreenMode: 0x178226be0; size = 1125.000000 x 2001.000000> // ZOOMED