iPhone4:阻止UIImageView缩放
我正在下载大量图像以向用户显示。
每个图像的尺寸均为 512x512。
在正常分辨率的 iPhone 中,一切正常,
但在 iPhone4 中,它们看起来是按比例缩放的。
如果此图像是从资源中获取的,
我只需在图像名称中添加一个 @2x
即可,一切正常,
问题是这些图像是从网络动态加载的。
如何防止 UIImageView 在视网膜显示屏上放大?
编辑: 以下是屏幕截图:
谢谢大家。
I'm downloading a lot of images to display to the user.
Each of this images have 512x512.
In a normal resolution iPhone, everything works fine,
but in the iPhone4, they appear scaled.
If this images were being fetched from the resources,
I would simply add a @2x
to the image name and everything would work,
the problem is that this images are dynamically loaded from the web.
How can I prevent this UIImageViews from scaling up on the retina display?
EDIT:
Here are the sreenshot:
Thank you all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看这段代码 - 当我想控制图像是否以scale=2或scale=1加载时,我在 UIImage 类别中使用它...查看 NSData 获取文件内容的位置(在我的代码中)并替换使用从网络获取图像的代码:
因此,技巧在于 UIImage 类的“initWithCGImage”的“scale”参数中,如果要加载高分辨率图像,则传递 2.0;如果要加载低分辨率图像,则传递 1.0 - 这就像您对高分辨率图像加载的最大控制。
最好的,马林
look at this code - I use it in a UIImage category when I want to control whether the image would be loaded with scale=2 or scale=1 ... See where NSData fetches the content of the file (in my code) and replace with your code that fetches images from the web :
So the trick is in the "scale" parameter of the "initWithCGImage" of the UIImage class, pass 2.0 if you are loading hi res images, or pass 1.0 if you are loading low res images - that's like the greatest control you take over the hi res image loading.
best, Marin
也许尝试检查设备是否有视网膜显示屏,以及是否尝试缩小图像。您可以通过以下方式查看它是否具有视网膜显示屏:
让我知道这是否有效。
Maybe try to check if the device has retina display and if it does try scaling the image down. You can see if it has retina display with:
Let me know if that does the trick.