Knowing device type -- Retina/non-Retina
15,114
Solution 1
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]
&& [[UIScreen mainScreen] scale] >= 2.0) {
// Retina
} else {
// Not Retina
}
Solution 2
You can check the scale
property on [UIScreen mainScreen]
if it is 2.0 you are running on retina, if it is 1.0 you are not. You can also get the scale from the current CoreGraphics Context.
Related videos on Youtube
Author by
Abhinav
Updated on December 10, 2020Comments
-
Abhinav over 3 years
Possible Duplicate:
Detect Retina DisplayHow can we know if a device has a retina display or not from objective C code?
-
Daniel T. about 13 yearsWhy would you need that?
-
occulus about 13 yearsWhat has the time zone got to do with Retina display?
-
-
Stanislav Yaglo about 13 yearsAnd the application will crash if the user runs it on iOS < 4
-
Noah Witherspoon about 13 yearsThis is a terrible idea—it's not future-proof at all, and doesn't even account for the fourth-gen iPod touch, which also has a Retina display. The
UIScreen
class'sscale
property, as described in the other answers, is the correct way to do this. -
onnoweb about 13 yearsGood point. I stand corrected.
-
GorillaPatch about 13 yearsCorrect. This is why you want to check first if [[UIScreen mainScreen] respondsToSelector:@selector(scale)] is true. This is the general concept of how you would code to ensure backwards compatibility.
-
shabbirv over 9 yearsThis should probably be >= 2.0 now (iPhone 6/6+)