简体   繁体   English

如何在iOS中正确管理大量图像

[英]How to properly manage large amount of images in iOS

In my application i display quite a large amount of images approximately 200, sooner or later I'm getting memory warning but I don't know what to do next 在我的应用程序中,我迟早会显示大约200张大量图像,但是我收到了内存警告,但我不知道下一步该怎么做

I have a subclass of UIImageView that downloads images asynchronously and displays them like this 我有一个UIImageView的子类,它异步下载图像并像这样显示它们

self.image = [[[UIImage alloc] initWithData:receivedData] autorelease];

How and when should I clean up the memory? 我应该如何以及何时清理内存?

Thanks in advance. 提前致谢。

Try use a small images in list. 尝试使用列表中的小图像。 On click on small image, show a large image. 单击小图像时,显示大图像。 Try use optimization methods for this case:) 在这种情况下,请尝试使用优化方法:)

once all images are downloaded they are all on the screen 一旦下载了所有图像,它们都将显示在屏幕上

Composite what you can (into one image), ideally on the server side so you have less to download, load into memory, and render on the client side. 可以将所有内容合成(成一张图像),最好是在服务器端,这样您就可以更少地下载,加载到内存中以及在客户端进行渲染。

As well, make sure the images are the size you will draw them at. 同样,确保图像的大小与绘制时的大小相同。 This can save a lot of memory and also processing (unless you are using shoddy or fast rescaling). 这样可以节省大量内存并进行处理(除非您使用的是伪劣或快速重新缩放)。

There's a lot of context missing in your post. 您的帖子中缺少很多上下文。 If a solution were universal and trivial, would you not assume there's a good chance it's already being used by the system's frameworks? 如果解决方案是通用且琐碎的,您是否不认为该系统的框架已经很好地使用了该解决方案?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM