iPhone 4 640x960 [duplicate]
Possible Duplicate:
How t开发者_StackOverflow中文版o 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.
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.
精彩评论