user392406
user392406

Reputation: 1323

iPad3 high resolution retina display issue

I am developing an app for iPad3(Retina Display) using Xcode 4.2 [iOS SDK 5.0]. I am using following code snippet for detecting retina (high-resolution) display.

 if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) 
{
NSLog(@"scale = %f",[[UIScreen mainScreen] scale]);
if ([[UIScreen mainScreen] scale] > 1.0) {
    NSLog(@"Retina Display iPad3");
} 
else    
{
    NSLog(@"Non Retina Display iPad 1/2");
}
}

When I install app on iPad3 device it is showing output:

scale = 1.00000;

Non Retina Display iPad 1/2.

Above code is not detecting Retina display.

I've tried all the codes related to retina display detection from google but all codes failed to detect retina display. Is there any method to detect iPad 3 retina display.

Thank you in advance.

Upvotes: 3

Views: 5659

Answers (3)

Will Pragnell
Will Pragnell

Reputation: 3123

For your app to support the new iPad retina display, you need to develop and build against the 5.1 SDK (which I think means you need to use XCode 4.3).

Upvotes: 9

xda1001
xda1001

Reputation: 2459

+ (BOOL)isRetina
{
    if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2.0) {
        return YES;
    }
    return NO;
}

I have tested in the iPad3, this method return YES.

Upvotes: 8

Folkert van Heusden
Folkert van Heusden

Reputation: 534

Try replacing:

if ([[UIScreen mainScreen] scale] > 1.0) {

by

if ([[UIScreen mainScreen] scale] >= 1.0) {

(I might be missing the point here, but if iPad3 has scale of 1.0, then '> 1.0' is incorrect)

Upvotes: -1

Related Questions