1

Possible Duplicate:
How to differentiate between iphone4 and iphone 3

Well, I know all the @2x stuff and already read the other stackoverflow threads and apple reference regarding the retina display and high res support to no avail.

I'm loading an image from a remote server which supports a resolution request parameter. For iPhone4 I want to request a larger resolution image.

How do I test if I'm on iPhone 4 ?

Using the "model" field on UIDevice is not an option because I'm not getting the right value in simulator.

0

1 Answer 1

4

I use this code for similar purposes.

// Return YES if we're running on a device with a retina display.
BOOL hasRetinaDisplay(void)
{
        if([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
                return [[UIScreen mainScreen] scale] == 2.0 ? YES : NO;

        return NO;
}

This works in that UIScreen only responds to scale on versions of iOS that can run on devices with retina displays, so if UIScreen doesn't respond to scale, then we know by default, no retina screen. If it does, then check its scale factor, 1.0 is no retina display, 2.0 is iPhone4.

2
  • Of course, UIScreen, how didn't I think of that. Thanks. Jul 26, 2010 at 14:00
  • If you need the check in different locations within your code, you can put the above code in a category of UIScreen, then just call: [[UIScreen mainscreen] isRetina] for example.
    – user111823
    Jun 7, 2011 at 11:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.