sdwebimage 关于指定图片更新缓存总是

jrl5365 2016-07-04 04:25:09
sd_setImageWithURL(NSURL(string: image_thumb), placeholderImage: UIImage(named: "Slice"), options: .RefreshCached)

我列表中有60条记录图片能正常加载与显示出来,但当我修改(旋转)了其中一张图片,图片的路径和名称是没有发生变化的,但缓存一直没有刷新过来,哪位大佬能提示一下,要如何才能让指定的图片重新下载一次,或是清除指定图片的缓存,再重新下载新的图片
...全文
1384 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
南枫小谨 2016-08-31
  • 打赏
  • 举报
回复
[imageview sd_setImageWithURL:url placeholderImage:image options:SDWebImageRefreshCached completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { }]; viewdidload 或init方法里面加入-(void)sdWEbDownloaderRegister{ SDWebImageDownloader *imgDownloader = SDWebImageManager.sharedManager.imageDownloader; imgDownloader.headersFilter = ^NSDictionary *(NSURL *url, NSDictionary *headers) { NSFileManager *fm = [[NSFileManager alloc] init]; NSString *imgKey = [SDWebImageManager.sharedManager cacheKeyForURL:url]; NSString *imgPath = [SDWebImageManager.sharedManager.imageCache defaultCachePathForKey:imgKey]; NSDictionary *fileAttr = [fm attributesOfItemAtPath:imgPath error:nil]; NSMutableDictionary *mutableHeaders = [headers mutableCopy]; NSDate *lastModifiedDate = nil; if (fileAttr.count > 0) { if (fileAttr.count > 0) { lastModifiedDate = (NSDate *)fileAttr[NSFileModificationDate]; } } NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; formatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; formatter.dateFormat = @"EEE, dd MMM yyyy HH:mm:ss z"; NSString *lastModifiedStr = [formatter stringFromDate:lastModifiedDate]; lastModifiedStr = lastModifiedStr.length > 0 ? lastModifiedStr : @""; [mutableHeaders setValue:lastModifiedStr forKey:@"If-Modified-Since"]; return mutableHeaders; }; } 即可
jrl5365 2016-07-06
  • 打赏
  • 举报
回复
打一下,老司机,帮帮忙
jrl5365 2016-07-05
  • 打赏
  • 举报
回复
引用 楼主 jrl5365 的回复:
sd_setImageWithURL(NSURL(string: image_thumb), placeholderImage: UIImage(named: "Slice"), options: .RefreshCached) 我列表中有60条记录图片能正常加载与显示出来,但当我修改(旋转)了其中一张图片,图片的路径和名称是没有发生变化的,但缓存一直没有刷新过来,哪位大佬能提示一下,要如何才能让指定的图片重新下载一次,或是清除指定图片的缓存,再重新下载新的图片
因为我的图片只做了旋转处理,所以没法更换图片....
网络咖啡 2016-07-04
  • 打赏
  • 举报
回复
一般后台更新图片以后,需要更新图片的文件名

1,420

社区成员

发帖
与我相关
我的任务
社区描述
Swift,苹果于2014年WWDC(苹果开发者大会)发布的新开发语言,可与Objective-C共同运行于MAC OS和iOS平台,用于搭建基于苹果平台的应用程序。
swift 技术论坛(原bbs)
社区管理员
  • Swift
  • 网罗开发
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧