简体   繁体   中英

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.

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. 在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM