美文网首页
SDWebImage加载图片的URL是同一个(如何处理)

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

作者: Fosen波波 | 来源:发表于2018-04-09 14:19 被阅读127次

直接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;
}

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

相关文章

网友评论

      本文标题:SDWebImage加载图片的URL是同一个(如何处理)

      本文链接:https://www.haomeiwen.com/subject/fdkihftx.html