如何检查iOS设备是否是视网膜显示器iPod touch?

Pro*_*ber 0 iphone ipod-touch ios

有没有一种安全的方法来确定某个设备是否属于特定型号?例如,我必须知道用户使用的设备是否是视网膜显示器iPod touch.

小智 8

NSRange r = [[[UIDevice currentDevice] model] rangeOfString:@"iPod"];
float s = [[UIScreen mainScreen] scale];

if (r.location != NSNotFound && s > 1.5f) {
    // retina iTouch
}
Run Code Online (Sandbox Code Playgroud)