无标题文章

ios开发 如何让sdwebimage不缓存图片 每次都重新加载url

可以使用这个方法

- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock;

//放在cell里赋值 [cell.img sd_setImageWithURL:[NSURL URLWithString:_dataDict[@"face"]] placeholderImage:nil options:SDWebImageRefreshCached completed:nil];

(这样可以让每次加载的头像都不同)

调用的时候设置下:

options = SDWebImageRefreshCached,该选项的含义如下:

/**

* Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed.

* The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation.

* This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics.

* If a cached image is refreshed, the completion block is called once with the cached image and again with the final image.

/*

即使图像被缓存,也要尊重HTTP响应缓存控制,如果需要,从远程位置刷新映像。

*磁盘缓存将由NSURLCache而不是SDWebImage处理,导致轻微的性能下降。

*此选项有助于处理在相同请求URL之后变化的图像,例如 Facebook图表api简介图片。

*如果缓存的图像被刷新,则使用缓存的图像再次调用完成块,并再次使用最终的图像。

*/

你可能感兴趣的:(无标题文章)