ipad: how can i detect ipad3 for in my application?

322 Views Asked by At

i am working in an app in which i have images , now the problem is that ipad3 has retina display is there any method in ios5 by which i can identify whether the device is ipad3 or ipad2.I want my app to be worked in both the devices.Is there any solution for this

2

There are 2 best solutions below

0
On BEST ANSWER

Can't you just use the @2x suffix?

Eg, you have image fancyBackground.png for regular ipad, and [email protected] for retina display?

When you do this, it will automatically use the correct image for the type of display that the device has (retina devices will use @2x-suffixed image files if they exist).

You can detect if a device is iPad by using:

UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad

You can detect if a device is retina by using:

[[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] >= 2.0
0
On
  • (NSString *)deviceVersion

{

size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *answer = (char*)malloc(size);
sysctlbyname("hw.machine", answer, &size, NULL, 0);
NSString *platform = [NSString stringWithCString:answer encoding: NSUTF8StringEncoding];
free(answer);
NSLog(@"Platform: %@", platform);

return platform;

}

Here is the method through you can detect weather device is ipad2,ipad3,ipod.. u can return a value and check against a value whatever it is.