iOS - 查看高分辨率图像

标签 ios memory memory-management uiimageview uiimage

我想在 ImageView 中显示高分辨率图像。这是我做的

  1. 在后台准备 UIImage
  2. 加载文件后,切换到主线程
  3. 显示图像[使用 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/

相关文章:

node.js - 确保 NODE_OPTIONS --max-old-space-size 正常工作

ios - 什么是 NSAssert1?

iOS:SWRevealViewController 和多个 NavigationControllers

r - R Windows 64 位版本中尚不支持长向量错误

windows - 不同的 Windows 操作系统使用了多少个安全环?

python - numpy: bool 索引和内存使用

Perl:如何在不访问 Perl 变量的情况下释放为标量分配的内存?

ios - UITableView 显示循环的最后一个值

iphone - 突出显示单个烛条的核心图

在 c 中创建字符串列表不起作用?