Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect iphone 5 4" screen [duplicate]

Possible Duplicate:
How to detect iPhone 5 (widescreen devices)?

Is there a way I can detect if the current device is the iphone 5? More specifically if it's using the new 4" screen?

like image 850
Hackmodford Avatar asked Sep 21 '12 17:09

Hackmodford


2 Answers

Use this

#define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES)
like image 172
Vladyslav Avatar answered Oct 02 '22 13:10

Vladyslav


I think you should concentrate on preferred display mode, rather than detecting iPhone5. Who knows what devices Apple will manufacture, but if your software supports that mode, it will be futureproof.

BOOL isiPhone5 = CGSizeEqualToSize([[UIScreen mainScreen] preferredMode].size,CGSizeMake(640, 1136));

In the future, folks might want to change preferred display mode on the fly. For example disconnect AppleTV from 720p tv and plug to 1080p, without restarting the app of course.

like image 34
bioffe Avatar answered Oct 02 '22 12:10

bioffe