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.

Share:
15,114

Related videos on Youtube

Abhinav
Author by

Abhinav

Updated on December 10, 2020

Comments

  • Abhinav
    Abhinav over 3 years

    Possible Duplicate:
    Detect Retina Display

    How can we know if a device has a retina display or not from objective C code?

    • Daniel T.
      Daniel T. about 13 years
      Why would you need that?
    • occulus
      occulus about 13 years
      What has the time zone got to do with Retina display?
  • Stanislav Yaglo
    Stanislav Yaglo about 13 years
    And the application will crash if the user runs it on iOS < 4
  • Noah Witherspoon
    Noah Witherspoon about 13 years
    This 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's scale property, as described in the other answers, is the correct way to do this.
  • onnoweb
    onnoweb about 13 years
    Good point. I stand corrected.
  • GorillaPatch
    GorillaPatch about 13 years
    Correct. 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
    shabbirv over 9 years
    This should probably be >= 2.0 now (iPhone 6/6+)

Related