Ios 如何检测视网膜高清显示器?

Ios 如何检测视网膜高清显示器?,ios,objective-c,iphone,cocoa-touch,Ios,Objective C,Iphone,Cocoa Touch,UIScreen在iOS 8中有一个新的nativeScale属性,但文档中对此只字未提 @property(nonatomic, readonly) CGFloat nativeScale 还有一个scale属性,但文档称视网膜显示为2 @property(nonatomic, readonly) CGFloat scale 我想知道是否有办法区分显示器。我之所以需要知道设备是否有视网膜高清显示器,是因为我想根据显示器要求不同大小的图像 @property(nonatomic, reado

UIScreen
在iOS 8中有一个新的
nativeScale
属性,但文档中对此只字未提

@property(nonatomic, readonly) CGFloat nativeScale
还有一个
scale
属性,但文档称视网膜显示为2

@property(nonatomic, readonly) CGFloat scale
我想知道是否有办法区分显示器。我之所以需要知道设备是否有视网膜高清显示器,是因为我想根据显示器要求不同大小的图像

@property(nonatomic, readonly) CGFloat scale

谢谢你的帮助

下面的可以很好地检测iPhone6Plus上的显示器类型

if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 3.0)
    NSLog(@"Retina HD"); 
else
    NSLog(@"Non Retina HD");
检查以下代码:

 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);
参考:


缩放属性将被使用它显示视网膜高清显示的3我得到
2
但我运行的是iPhone 6模拟器。在设备上运行时是否显示
3
?iPhone 6 plus的ratina HD不正确,谢谢您的纠正+1我已经检查了iPhone 6+3它给我的问题是关于视网膜的HD@Bhumit这是答案,似乎是在我的评论之后编辑的。现在可以正确地调用
响应选择器
不需要了(除非你想支持iOS 3.2或更低版本),我完全得到了2。。。。我在调试器中运行,这有关系吗?你的代码在iPhone 6S上,最晚在iPhone 7上会出现什么问题?同意,这基本上保证将来会出现问题。在
[UIScreen Main Screen]
上检查
刻度是一种更好的方法。