SDWebImage加载图片的URL是同一个(如何处理)

直接code!

加载图片时用的方法如下:

[self.imageView sd_setImageWithURL:[NSURL URLWithString:urlStr]];

加载不出来最新的图片,改用下面的方法,去解决问题:

[self.imageView sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:nil options:SDWebImageRefreshCached];

除了上面的修改之外,我们还需要在SDWebImage的内部,SDWebImageManager.m文件中,大概180行左右吧,把之前的代码:

if (image && options & SDWebImageRefreshCached) {
    // force progressive off if image already cached but forced refreshing
    downloaderOptions &= ~SDWebImageDownloaderProgressiveDownload;
    // ignore image read from NSURLCache if image if cached but force refreshing
    downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse;
}

更换成如下:

if (image && options & SDWebImageRefreshCached) {
    // force progressive off if image already cached but forced refreshing
    downloaderOptions &= ~SDWebImageDownloaderProgressiveDownload;
替换下面
    // remove SDWebImageDownloaderUseNSURLCache flag
    downloaderOptions &= ~SDWebImageDownloaderUseNSURLCache;
替换上面
    // ignore image read from NSURLCache if image if cached but force refreshing
    downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse;
}

好久没有写更新了,以后要坚持啊!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容