在运行时替换包中的图像
我可以在运行时替换包中的图像吗?基本上,我的捆绑包中有一些图像,如果图像有任何更改,我也会从服务器获取它们。我可以在运行时将它们放入包中,这样我就不需要更改代码来选择图像吗?
Can I replace images in bundle at run time? Basically, I have some images part of my bundle and also I will have them from the server if there is any change in the image. Can I place them in the bundle at run time so that I need not to change my code to pick the image?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法更改应用程序包的内容。
但是,可以将图像存储在应用程序的文档文件夹中。然后,您将能够覆盖这些图像,以防需要更改它们。
有两种方法可以实现此目的:
You cannot change the contents of an Application bundle.
It is however possible to store the images in the Application's documents folder. Then you'll be able to overwrite those images in case they need to be changed.
There are two ways to achieve this:
您无法在运行时更改捆绑包。这将阻止应用程序运行,因为配置文件将不再有效。你会在 stackoverflow 上找到大量如何处理 iOS 提供的沙箱文件夹的代码。
编辑
有用的问题/解答
You cannot change the bundle on runtime. This will prevent the app from running, as the profile won't be valid anymore. You will find tons of code how to deal with the sandbox folders provided by iOS on stackoverflow.
edit
Useful questions / answers