Reputation: 40030
UIScreen
has a new, nativeScale
property in iOS 8 but the documentation does not say a word about it.
@property(nonatomic, readonly) CGFloat nativeScale
There is also a scale
property but the docs say it is 2 for retina displays.
@property(nonatomic, readonly) CGFloat scale
I am wondering if there is a way to distinguish the displays. The reason why I need to know whether the device has Retina HD display is because I want to request images with different sizes based on the displays.
Thanks for any help!
Upvotes: 0
Views: 1697
Reputation: 8349
Check the below code:
CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
CGSize screenSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);
NSLog(@"WIDTH:%f",screenSize.height);
NSLog(@"WIDTH:%f",screenSize.width);
float height =screenSize.height;
float width = screenSize.width;
NSString *deviceType=@"";
if (height==1136.000000 && width==640.000000)
{
deviceType =@"iPhone 5,5S and 5C Retina";
}
if (height==1920.000000 && width==1080.000000)
{
deviceType =@"iPhone 6 Plus Retina Downsample";
}
if (height==2208.000000 && width==1242.000000)
{
deviceType =@"iPhone 6 Plus Retina";
}
if (height==1334.000000 && width==750.000000)
{
deviceType =@"iPhone 6 Retina";
}
if (height==960.000000 && width==640.000000)
{
deviceType =@"iPhone 4 and 4S Retina";
}
if (height==480.000000 && width==320.000000)
{
deviceType =@"iPhone 3g and 3gs Non retina ";
}
NSLog(@"Your Result:%@",deviceType);
Reference:
Upvotes: -1
Reputation: 5065
Below works very well to detect type of display on iPhone6Plus.
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 3.0)
NSLog(@"Retina HD");
else
NSLog(@"Non Retina HD");
Upvotes: 3