__block UIActivityIndicatorView *activityIndicator;
__weak UIImageView *weakImageView = self.headpic;
[self.headpic setImageWithURL:imageUrl placeholderImage:nil options:SDWebImageProgressiveDownload progress:^(NSInteger receivedSize, NSInteger expectedSize){
if (!activityIndicator) {
[weakImageView addSubview:activityIndicator = [UIActivityIndicatorView.alloc initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]];
activityIndicator.center = weakImageView.center;
[activityIndicator startAnimating];
}
}
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType){
[activityIndicator removeFromSuperview];
activityIndicator = nil;
}];
此代码可以设置headpic的图像,我想同时下载服务器图像(从imageUrl)到NSHomeDirectory
,该怎么办?
答案 0 :(得分:0)
在本地查看EGOCache的商店图片。 https://github.com/enormego/EGOCache 您可以使用默认的EGOCache目录(在NSCachesDirectory中)或使用您自己的目录初始化它。
用法非常简单:
[[EGOCache globalCache] setImage:image forKey:@"your_key"];