简体   繁体   English

如何使用SDWebImage从内存缓存中获取图像?

[英]How to get the image from in memory cache using SDWebImage?

I have implemented SDWebImage in cellforrowatindexpath method. 我已经在cellforrowatindexpath方法中实现了SDWebImage。 The problem here is when i scroll down the tableview the images are loading from web which is expected but when i scroll up the tableview the images are again downloading. 这里的问题是当我向下滚动tableview时,图像是从Web加载的,但是当我向上滚动tableview时,图像又被下载了。 What is the way to get rid of this problem. 摆脱这个问题的方法是什么。 I don't want to load images from url overtime (since there is a usage limit with the web service call). 我不想从URL超时加载图像(因为Web服务调用存在使用限制)。 I chose to use SDWebImage API for in memory cache so that once the images are loaded they are taken from cache to show it on the UI instead of making the web service call everytime. 我选择在内存缓存中使用SDWebImage API,这样,一旦加载了图像,便会从缓存中获取它们以在UI上显示它,而不是每次都调用Web服务。 Here is my code: 这是我的代码:

[cell.placeImage sd_setImageWithURL:url placeholderImage:nil options:SDWebImageCacheMemoryOnly];

The above line is the only code in that method. 上一行是该方法中的唯一代码。 Please help me. 请帮我。 Any kind of help is appreciated. 任何帮助都将受到赞赏。 I have seen other questions in this community but nobody said how to get an image from the cache memory. 我在这个社区中看到了其他问题,但是没有人说过如何从缓存中获取图像。

要刷新图像,应使用以下选项: SDWebImageRefreshCached

[imageView sd_setImageWithURL:url placeholderImage:nil options:SDWebImageRefreshCached];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM