- (void)downloadAction:(UIButton
*)sender{
[[SDWebImageManager sharedManager] downloadImageWithURL:[NSURL URLWithString:self.model.url] options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) {
NSLog(@"处理下载进度");
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (error) {
NSLog(@"%@",error);
}
if (image) {
[[SDWebImageManager sharedManager] downloadImageWithURL:[NSURL URLWithString:self.model.url] options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) {
NSLog(@"处理下载进度");
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (error) {
NSLog(@"%@",error);
}
if (image) {
//将图片写入相册中
UIImageWriteToSavedPhotosAlbum(image,
self,
@selector(imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:),
nil);
NSLog(@"图片操作");
}
}];
}
NSLog(@"图片操作");
}
}];
}
- (void)imageSavedToPhotosAlbum:(UIImage
*)image didFinishSavingWithError:(NSError
*)error contextInfo:(void
*)contextInfo
{
NSString *message = @"呵呵";
if (!error) {
message = @"成功保存到相册";
}else
{
message = [error description];
}
NSLog(@"message is %@",message);
{
NSString *message = @"呵呵";
if (!error) {
message = @"成功保存到相册";
}else
{
message = [error description];
}
NSLog(@"message is %@",message);
}