我在项目中使用AlamofireImage。我使用 someImageView.af_setImageWithURL(url)很多。
I use AlamofireImage in my project. I use someImageView.af_setImageWithURL(url) a lot.
但是在某些时候我需要手动获取图像来自imageCache,因为我不想将它应用于UIImageView。
However at some point I need to fetch an image manually from the imageCache, because I do not want to apply it to an UIImageView.
这带来了2个问题:
推荐答案
问题1
这与 UIImageView的缓存不同使用。如果您需要访问相同的缓存,可以通过 UIImageView.af_sharedImageDownloader.imageCache 来实现。
Question 1
That is not the same cache that UIImageView uses. If you need access the same cache, you can do so by UIImageView.af_sharedImageDownloader.imageCache.
您需要使用完全相同的 NSURLRequest 和相同的 ImageFilter 。如果您使用相同的 NSURLRequest 和相同的 ImageFilter ,则会直接从缓存中提取图像(如果存在)。如果您使用的是另一个 ImageFilter ,则原始图像很可能会从 NSURLCache 中拉出,然后 ImageFilter 将在其上运行,放入 AutoPurgingImageCache 并返回。如果 NSURLRequest 不同,则需要再次下载新图像。
You will need to use the exact same NSURLRequest and the same ImageFilter. If you use the same NSURLRequest and the same ImageFilter, the image will be directly fetched from the cache if it exists. If you are using a different ImageFilter, then the original image will most likely be pulled from the NSURLCache, then the ImageFilter will be run over it, placed into the AutoPurgingImageCache and returned. If the NSURLRequest is different, the new image will need to be downloaded again.
更多推荐
Alamofire图片:在af
发布评论