Memory consumption while loading a large image in uiimageview in

纵然是瞬间 提交于 2019-12-06 21:01:32

Solution to this problem consists of either loading scaled version of the image (*1) or you have option to display it in full resolution with help of CATiledLayer(*2).

  1. [UIImage imageWithCGImage:scale:orientation:];
  2. CATiledLayer example

Addendum: If your image source is Photo Library, ALASSet provides already scaled image to full screen and full resolution image. You can use combination of both with CATiledLayer. Full screen image is added to layer beneath the CATiledLayer to serve as placeholder while you're waiting for tiles in CATiledLayer to load.

Well, according to the documentation :

You should avoid creating UIImage objects that are greater than 1024 x 1024 in size.

Reduce your image then load it in your ImageView, there are plenty of libraries to do this, here is one :

https://github.com/Nyx0uf/NYXImagesUtilities

SriPriya

You can use this for scaling The method is described simply in the following link:

How to scale a UIImageView proportionally?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!