[英]downloading image into NSHomeDirectory by using SDWebImage
__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;
}];
该代码可以设置头像的图像,并且我想同时将服务器图像(从imageUrl)下载到NSHomeDirectory
,该怎么办?
在EGOCache中查找本地存储图像。 https://github.com/enormego/EGOCache您可以使用默认的EGOCache目录(位于NSCachesDirectory内部)或使用您自己的目录对其进行初始化。
用法很简单:
[[EGOCache globalCache] setImage:image forKey:@"your_key"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.