【问题标题】:Monotouch serialize UIImageMonotouch 序列化 UIImage
【发布时间】:2010-05-09 12:08:12
【问题描述】:

我需要在本地缓存图像并考虑将它们保存为 SerializableDictionary

SerializableDictionary 来自:http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx

我想知道这是不是

a:处理图像缓存的好方法(对于离线模式 - 数据不断更新,因此首先从网络中提取)。

b:我该怎么做?

我似乎只剩下以下 xml:

    <?xml version="1.0" encoding="us-ascii"?>
<dictionary>
  <item>
    <key>
      <string>http://img.theguidestar.com/thumb/491520.png</string>
    </key>
    <value>
      <UIImage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <Handle />
        <Size>
          <Width>0</Width>
          <Height>0</Height>
        </Size>
      </UIImage>
    </value>
  </item>
</dictionary>

我应该做些什么来使其序列化图像本身?

w://

【问题讨论】:

  • 放弃了这一点 - 认为最好使用 orig url 作为键和 guid 作为文件名来存储对光盘上正确文件的引用。工作得很好 w://

标签: c# serialization xamarin.ios


【解决方案1】:

UIImage 和 CGI​​Mage 不允许轻松访问它们的数据。因此,在 XML 文档中序列化图像是相当困难的。

您可以使用以下解决方案:

  • 从网络中检索图像并将其存储在用户的文档文件夹中。
  • 将图片的 URL 映射到字典中图片的本地路径。
  • 使用字典作为缓存索引来访问图像。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-20
  • 1970-01-01
  • 2012-01-17
  • 2011-12-06
  • 2011-02-05
  • 1970-01-01
相关资源
最近更新 更多