美文网首页
[iOS] SDWebImage 刷新图片缓存方法

[iOS] SDWebImage 刷新图片缓存方法

作者: 两年如歌 | 来源:发表于2016-04-13 19:11 被阅读187次

    将 SDWebImageManager.m 文件中的 downloadImageWithURL 方法中的 ( 代码在176行 )

    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 is cached but force refreshing
      downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse;
    }
    

    之后在工程中使用如下方法:

    [self.imageView sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage new] options:SDWebImageRefreshCached];
    

    相关文章

      网友评论

          本文标题:[iOS] SDWebImage 刷新图片缓存方法

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