简体   繁体   English

iPad3高分辨率视网膜显示问题

[英]iPad3 high resolution retina display issue

I am developing an app for iPad3(Retina Display) using Xcode 4.2 [iOS SDK 5.0]. 我正在使用Xcode 4.2 [iOS SDK 5.0]为iPad3(Retina Display)开发应用程序。 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: 当我在iPad3设备上安装应用程序时,它显示输出:

scale = 1.00000; scale = 1.00000;

Non Retina Display iPad 1/2. 非Retina显示器iPad 1/2。

Above code is not detecting Retina display. 以上代码未检测到Retina显示。

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. 有没有办法检测iPad 3视网膜显示器。

Thank you in advance. 先感谢您。

为了让您的应用程序支持新的iPad视网膜显示器,您需要开发和构建5.1 SDK(我认为您需要使用XCode 4.3)。

+ (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 . 我在iPad3上测试过,这个方法返回YES

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) (我可能会忽略这一点,但如果iPad3的比例为1.0,则'> 1.0'不正确)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM