Oleksandr Matrosov
Oleksandr Matrosov

Reputation: 27187

How to detect iPhone 6 (6 plus) on simulator

I have found this nice defines:

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)

#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))

#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
#define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)

But when I run iPhone 6 simulator or iPhone 6 plus simulator it every time work as iPhone 5.

I have checked the screen size:

(lldb) po [UIScreen mainScreen]
<UIScreen: 0x7ffb3a402930; bounds = {{0, 0}, {320, 568}}; mode = <UIScreenMode: 0x7ffb3a520a80; size = 640.000000 x 1136.000000>>

and seems everting is clear why it points me to iPhone 5 instead of iPhone 6 or iPhone 6 plus.

Upvotes: 1

Views: 394

Answers (1)

Juan de la Torre
Juan de la Torre

Reputation: 1297

You have to add the appropriate launch images so the app device/simulator starts using the real size and not a zoomed or emulated size, until you add a launch image for Retina HD 5.5 and Retina HD 4.7 you won't be using the new sizes.

Click the small grey arrow on the Launch Images Source in your Project General Settings and add the appropriate launch images. enter image description here

Upvotes: 3

Related Questions