问题
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.
回答1:
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).
回答2:
+ (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
.
回答3:
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)
来源:https://stackoverflow.com/questions/9870712/ipad3-high-resolution-retina-display-issue