我想在 ImageView 中显示高分辨率图像。这是我做的
- 在后台准备 UIImage
- 加载文件后,切换到主线程
- 显示图像[使用 UIImageView 的 setImage:]
问题是第 3 步有延迟。它需要几秒钟并加载文件。如果它是一个大图像,我会收到内存警告和崩溃。 那么有没有一种方法可以让我从上到下绘制图像(就像浏览器那样)?我还需要保持图像的质量。
有什么方法可以达到我的要求。提前致谢
最佳答案
And if its a large image, I get the memory warning and a crash.
您似乎遇到了设备的一些“硬”(内存相关)限制,试图立即将图像加载并显示到内存中。
So is there a way by which i can draw images from top to bottom ( like how the browser does)?
您应该尝试使用 CATiledLayer,它提供了一种绘制非常大的图像而不会导致内存命中的方法。
Here你可以找到关于它的教程。
您还可以查看 PhotoScrollerNetwork项目:
blazingly fast tile rendering - visually much much faster than Apple's code (which uses png files in the file system)
you supply a single jpeg file or URL and this code does all the tiling for you, quickly and painlessly
关于iOS - 查看高分辨率图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16162790/