gpt4 book ai didi

c# - Xamarin 表格 : Image Cache

转载 作者:太空狗 更新时间:2023-10-30 00:49:00 24 4
gpt4 key购买 nike

您好,我正在尝试使用 xamarin Forms PCL 构建应用程序。我正在实现我在其中使用默认图像的图像库。所有图像都在 blob 上。我想下载图像并将该图像缓存在设备中,下载完成后我需要用它替换我的默认图像。下次加载应用程序时,仅当缓存中不存在图像时才下载图像。我没有得到任何用于图像缓存和从缓存加载图像的插件。我见过一个名为 FFFPLUGIN 的插件,但它没有用。知道我该如何实现吗?图片缓存

最佳答案

您可以在此处显示的 Xamarin Forms 中使用内置的 ImageCaching:

https://developer.xamarin.com/guides/xamarin-forms/working-with/images/#Downloaded_Image_Caching

Downloaded Image Caching

UriImageSource also supports caching of downloaded images, configured through the following properties:

CachingEnabled - Whether caching is enabled ( true by default).

CacheValidity - A TimeSpan that defines how long the image will be stored locally. Caching is enabled by default and will store the image locally for 24 hours. To disable caching for a particular image, instantiate the image source like this:

Image.Source = new UriImageSource {CachingEnabled = false,
Uri="http://server.com/image"}; To set a specific cache period (for
example, 5 days) instantiate the image source like this:


webImage.Source = new UriImageSource {
Uri = new Uri("https://xamarin.com/content/images/pages/forms/example-app.png"),
CachingEnabled = true,
CacheValidity = new TimeSpan(5,0,0,0) };

Built-in caching makes it very easy to support scenarios like scrolling lists of images, where you can set (or bind) an image in each cell and let the built-in cache take care of re-loading the image when the cell is scrolled back into view.

关于c# - Xamarin 表格 : Image Cache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41487647/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com