what is the code to detect whether ios app running in iPhone, iPhone Retina display, or iPad?
Background:
for my iPhone application I have defined i
Here's 2 useful class methods that I use, which directly answers your question - which you may want to use further down the line:
+(BOOL)isPad
{
#ifdef UI_USER_INTERFACE_IDIOM
return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;
#endif
return NO;
}
+(BOOL)hasRetinaDisplay
{
// checks for iPhone 4. will return a false positive on iPads, so use the above function in conjunction with this to determine if it's a 3GS or below, or an iPhone 4.
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2)
return YES;
else
return NO;
}