直接code糖荒!
加載圖片時(shí)用的方法如下:
[self.imageView sd_setImageWithURL:[NSURL URLWithString:urlStr]];
加載不出來最新的圖片舶沿,改用下面的方法特愿,去解決問題:
[self.imageView sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:nil options:SDWebImageRefreshCached];
除了上面的修改之外,我們還需要在SDWebImage的內(nèi)部光酣,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;
}
好久沒有寫更新了救军,以后要堅(jiān)持安埔臁!