看看这段代码 - 我在UIImage类中使用它,当我想控制图片是否会被加载scale = 2或scale = 1 ...看看NSData在哪里获取文件的内容(在我的码),并与您的代码是从网上获取的图像替换:
if ([[[UIDevice currentDevice] systemVersion] intValue] >= 4 && [[UIScreen mainScreen] scale] == 2.0) {
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
return [self initWithCGImage:[[UIImage imageWithData:[NSData dataWithContentsOfFile:path]] CGImage] scale:2.0 orientation:UIImageOrientationUp];
}
} else [ load here the image via imageWithContentsOfFile or whatever ]
因此,关键是在对的UIImage类的“initWithCGImage”的“规模”参数,通过2.0如果要加载高分辨率图像,或者如果你正在加载低分辨率图像则通过1.0 - 这就像你接管高分辨率图像加载的最大控制。
最好,马林
你是什么意思的扩大规模?你可以张贴一些截图吗? – 2010-11-04 10:42:52
你的意思是你的iphone4上的图像显示为256x256? – Bongeh 2010-11-04 10:51:41
它们的真实分辨率是512x512,但在iPhone4中,它们显示的尺寸是原来的两倍,因为每个点在视网膜显示中都是两个像素。我怎样才能防止这一点? – Tsimmi 2010-11-04 11:03:02