iOS SDWebImage(一)
/*
第一个参数:下载图片的url地址
第二个参数:占位图片
*/
//[cell.imageView sd_setImageWithURL:[NSURL URLWithString:appM.icon] placeholderImage:[UIImage imageNamed:@"Snip20160221_306"]];
/*
第一个参数:下载图片的url地址
第二个参数:占位图片
第三个参数:progress进度回调
receivedSize:已经下载的数据大小
expectedSize:要下载图片的总大小
第四个参数:
image:要下载的图片
error:错误信息
cacheType:缓存类型
imageURL:图片url
*/
[cell.imageViewsd_setImageWithURL:[NSURLURLWithString:appM.icon]placeholderImage:[UIImageimageNamed:@"Snip20160221_306"]options:0progress:^(NSIntegerreceivedSize,NSIntegerexpectedSize) {
NSLog(@"%f",1.0* receivedSize / expectedSize);
}completed:^(UIImage*image,NSError*error,SDImageCacheTypecacheType,NSURL*imageURL) {
NSLog(@"%zd",cacheType);
}];
缓存类型
网上下的
SDImageCacheTypeNone,
磁盘缓存
SDImageCacheTypeDisk,
内存缓存
SDImageCacheTypeMemory
options所有选项:
//失败后重试
SDWebImageRetryFailed = 1 << 0,
//UI交互期间开始下载,导致延迟下载比如UIScrollView减速。
SDWebImageLowPriority = 1 << 1,
//只进行内存缓存
SDWebImageCacheMemoryOnly = 1 << 2,
//这个标志可以渐进式下载,显示的图像是逐步在下载
SDWebImageProgressiveDownload = 1 << 3,
//刷新缓存
SDWebImageRefreshCached = 1 << 4,
//后台下载
SDWebImageContinueInBackground = 1 << 5,
//NSMutableURLRequest.HTTPShouldHandleCookies = YES;
SDWebImageHandleCookies = 1 << 6,
//允许使用无效的SSL证书
//SDWebImageAllowInvalidSSLCertificates = 1 << 7,
//优先下载
SDWebImageHighPriority = 1 << 8,
//延迟占位符
SDWebImageDelayPlaceholder = 1 << 9,
//改变动画形象
SDWebImageTransformAnimatedImage = 1 << 10,