如何将UIImage保存到应用程序的Bundle? [英] How to save a UIImage to the application's Bundle?

查看:68
本文介绍了如何将UIImage保存到应用程序的Bundle?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在从文档"目录中获取图像(使用-imageWithContentsOfFile :),没有问题,除了我无法立即显示图像(例如,一旦调用touchesEnded).我假设这与图像缓存有关,并且不缓存以上述方式创建的图像对象?因此,我想,我将在创建图像对象后对其进行缓存,然后通过-imageNamed:使用缓存的图像.那么如何将UIImage对象保存到应用程序的Bundle和/或缓存它?

I am currently getting images from the 'Documents' directory (using -imageWithContentsOfFile:) with no problems except that I cannot get the images to display immediately (for example as soon as touchesEnded was called). I am assuming that this has to do with image caching and that image objects created in the above way are not cached? So, I figure, I will cache the image object after creating it and then use the cached image using -imageNamed:. So how can I save a UIImage object to the application's Bundle and/or Cache it?

推荐答案

应用程序捆绑包一旦在iPhone上就无法修改.整个过程都是经过代码签名的,更改它会使它不再运行.

You can't modify the application bundle once it's on the iPhone. The entire thing is code signed, and changing it would cause it to not run any more.

为什么不预加载启动时所需的图像?不过请小心,因为大图像会占用大量内存,并且如果应用程序过多,内核可能会杀死您的应用程序.

Why don't you pre-load the images you need at startup? Be careful, though, as large images take up a lot of memory, and the kernel could kill your app if it goes overboard.

这篇关于如何将UIImage保存到应用程序的Bundle?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆