In iOS versions prior to iOS 8, to check whether the device is iPhone 5/iPhone 5s, checking [UIScreen mainScreen].bounds.size.height == 568.0 was enough. But in iOS 8.x onwards, this check may fail as the bounds are now orientation dependant. I need a solution to identify the iPhone 5s, 6 and 6+ devices without checking the iOS version.
Asked
Active
Viewed 856 times
2 Answers
0
You can check if
[UIScreen mainScreen].bounds.size.height == 568.0
and [UIScreen mainScreen].scale
to identify iPhone 6 and 6+
Note that this will not work if application is working on "zoomed" mode.
In this case iPhone 6 and 6+ will give scale 2.0

l0gg3r
- 8,864
- 3
- 26
- 46
-
Could you please explain what's zoomed mode for iPhone 6 & 6+? Please give a basic idea. I am new to this. – Rashmi Ranjan mallick Nov 11 '14 at 10:03
-
@RashmiRanjanmallick if you don't specify Splash images for iPhone 6 / 6+ (in ImageAssets for example) application will start working in zoomed mode, and the screen bounds will be 320 x 568 on both iPhone 6, 6+ – l0gg3r Nov 11 '14 at 10:05
-
Thanks a lot friend !!! I really don't what size of splash screens I should be adding to support iPhone 6 & 6+. Any help on this? – Rashmi Ranjan mallick Nov 11 '14 at 10:11
-
iPhone 6 - 750 x 1334 pixels, iPhone 6+ 1242 x 2208 pixels – l0gg3r Nov 11 '14 at 10:13
-
Thanks again. So, only adding the above two splash screens will do the work for me. Am I correct? Please confirm. – Rashmi Ranjan mallick Nov 11 '14 at 10:15
-
Yes, your application will start supporting iPhone 6 and 6+ (so you need to start supporting another screen size), I've added a small guide that can be helpful http://i.imgur.com/iONhe52.png – l0gg3r Nov 11 '14 at 10:17
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/64691/discussion-between-rashmi-ranjan-mallick-and-l0gg3r). – Rashmi Ranjan mallick Nov 11 '14 at 10:20
0
I was able to detect the devices using the following macros. This will be useful if you want identify the device, to perform some update on views(like updating frames on orientation changes). If you exactly want the device model/make, use this link (ios iphone get device model and make?) instead.
#define IS_IPHONE ((int)(MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)) == 480)
#define IS_IPHONE5 ((int)(MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)) == 568)
#define IS_IPHONE6 ((int)(MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)) == 667)
#define IS_IPHONE6PLUS ((int)(MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)) == 736)

Community
- 1
- 1
-
this wouldn't work if app is in "zoom" mode (splash screen missing for 6 or 6+) – l0gg3r Nov 11 '14 at 09:53
-
@l0gg3r:You are right, in zoomed mode this will fail. In zoomed mode The iPhone5 check will be true for iPhone6 and iPhone6+ also. So I will update the answer to cover that also. – Nov 12 '14 at 04:17
-
@l0gg3r:I said it was working for me is because, my requirement is to identify the device, to update the view's frames on orientation update. My app support both new resolutions, so no worries about zoomed mode. Also if the app is running in zoomed mode, we don't need to worry about that; the system will handle that case. Set the view's frames for iPhone 5 resolution and the system will zoom/scale it for the new resolution. – Nov 12 '14 at 04:50