Tsi*_*mmi 0 iphone cocoa-touch iphone-4 retina-display
我正在下载大量图像以显示给用户.
每个图像都有512x512.
在正常分辨率的iPhone中,一切正常,
但在iPhone4中,它们看起来是缩放的.
如果从资源中获取这些图像,
我只需添加一个@2x
图像名称,一切都会工作,
问题是这些图像是从网络动态加载的.
如何防止这个UIImageViews在视网膜显示器上放大?
编辑:这是sreenshot:
http://img836.imageshack.us/img836/5173/screenshot20101104at104.png
谢谢你们.
看看这段代码 - 当我想控制图像是否加载scale = 2或scale = 1时,我在UIImage类别中使用它...看看NSData在哪里获取文件的内容(在我的代码中)并替换使用从Web获取图像的代码:
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 ]
Run Code Online (Sandbox Code Playgroud)
所以诀窍在于UIImage类的"initWithCGImage"的"scale"参数,如果你正在加载高分辨率图像则传递2.0,或者如果你正在加载低分辨率图像则传递1.0 - 这就像你接受的最大控制权一样嗨res图像加载.
最好的,马林
归档时间: |
|
查看次数: |
1151 次 |
最近记录: |