标签:
SDWebImage提供了如下三个category来进行缓存。
以最为常用的UIImageView为例:
setImageWithURL:placeholderImage:options:
先显示 placeholderImage ,同时由SDWebImageManager 根据 URL 来在本地查找图片。downloadWithURL:delegate:options:userInfo:
SDWebImageManager是将UIImageView+WebCache同SDImageCache链接起来的类, SDImageCache: queryDiskCacheForKey:delegate:userInfo:
用来从缓存根据CacheKey查找图片是否已经在缓存中imageCache:didFindImage:forKey:userInfo:
webImageManager:didFinishWithImage:
来显示图片。notifyDelegate:
。imageCache:didFindImage:forKey:userInfo:
。进而回调展示图片。imageCache:didNotFindImageForKey:userInfo:
。SDWebImageDownloader
开始下载图片。connection:didReceiveData:
中利用 ImageIO 做了按图片下载进度加载效果。connectionDidFinishLoading:
数据下载完成后交给 SDWebImageDecoder
做图片解码处理。notifyDelegateOnMainThreadWithInfo:
宣告解码完成,imageDecoder:didFinishDecodingImage:userInfo:
回调给 SDWebImageDownloader。imageDownloader:didFinishWithImage:
回调给 SDWebImageManager 告知图片下载完成。SDWebImagePrefetcher
可以预先下载图片,方便后续使用。标签:
原文地址:http://www.cnblogs.com/Yishu/p/4912713.html