In low-memory situations, image data may be purged from a UIImage object to free up memory on the system.
有人知道这是如何工作的吗?看来这个过程是完全透明的,并且将在后台发生,不需要我的任何输入,但我无法以某种方式找到任何明确的文档。
第二,当我没有加载图像时,会发生这种数据清除吗? (我从 UIImagePicker 获取图像)。
情况如下:我正在使用 UIImagePickerController
拍照,并立即拍摄该图像并将其发送到新的 UIViewController
进行显示。将原始图像发送到新 Controller 会使我的应用程序崩溃,并在大约 30% 的情况下出现内存警告。调整图像大小需要一些时间,如果有第三个选项可供我使用,我宁愿不花这些时间。
最佳答案
我想这就是答案。在 initWithContentsOfFile:
的文档中,它说:
This method loads the image data into memory and marks it as purgeable. If the data is purged and needs to be reloaded, the image object loads that data again from the specified path.
UIImage
中的其他方法都没有提到清除,因此看来从文件初始化新图像是获得这种低内存行为的唯一方法。
关于iphone - UIImage 在低内存情况下如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2496714/