原因
因为 SDWebImage 的缓存机制, 相同的 URL 它就认为可以去到沙盒里面的缓存路片
解决方法
NSString *testImageUrl =
[_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;
}