在运行时替换软件包中的映像 [英] Replacing images in the bundle at run time

查看:106
本文介绍了在运行时替换软件包中的映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在运行时替换软件包中的图像吗?基本上,我有一些图像的一部分,我的包,如果图像有任何变化,我也将从服务器。

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?

推荐答案

您可以在运行时将它们放在包中,以便我不需要更改我的代码来选择图片。不能更改应用程序包的内容。

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:


  1. 启动时,检查文档目录中是否存在映像文件。

  2. 每次加载图像时,请检查文档目录中是否存在该图像。如果是,加载它,否则从bundle中加载一个。这避免了复制数据,从而导致更少的磁盘使用,但是更多的工作要实现。

这篇关于在运行时替换软件包中的映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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