原因
因?yàn)?SDWebImage 的緩存機(jī)制, 相同的 URL 它就認(rèn)為可以去到沙盒里面的緩存路片
解決方法
NSString *testImageUrl = "www.你的image.com";
[_IMG sd_setImageWithURL:[NSURL URLWithString:testImageUrl] placeholderImage:[UIImage imageNamed:@"1.png"] options:SDWebImageRefreshCached];
SDWebImageManager.m文件中寺庄,大概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 if cached but force refreshing
downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse;
}