直接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;
}
好久没有写更新了,以后要坚持啊!
网友评论