我在一个有图像的应用程序中工作,现在的问题是ipad3有视网膜显示器,在ios5中有什么方法可以让我识别设备是ipad3还是ipad2。我希望我的应用程序可以在devices.Is和ipad3两种模式下运行有什么解决方案吗
发布于 2012-05-11 13:05:33
你不能只使用@2x后缀吗?
例如,你有用于普通ipad的图像fancyBackground.png,和用于视网膜显示的fancyBackground@2x.png?
当您这样做时,它将自动使用设备所具有的显示器类型的正确图像(视网膜设备将使用@2x后缀的图像文件,如果它们存在)。
您可以使用以下命令检测设备是否为iPad:
UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad您可以使用以下命令来检测设备是否为视网膜:
[[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] >= 2.0发布于 2013-06-12 17:54:16
*)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;}
这里的方法是通过你可以检测天气的设备是ipad2,ipad3,ipod..你可以返回值,并检查一个值,不管它是什么。
https://stackoverflow.com/questions/10545697
复制相似问题