NSURL *url = [NSURL URLWithString:self.str];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [UIImage imageWithData:data];
// 保存图片到相册中
UIImageWriteToSavedPhotosAlbum(img, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
NSLog(@"保存乐乐乐乐乐乐乐乐");
- (void)image:(UIImage *) image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo
{
NSString *msg = nil ;
if (error != NULL)
{
msg = @"保存图片失败" ;
}
else // No errors
{
msg = @"保存图片成功" ;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:msg delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alert show];
}
保存图片到手机相册
最新推荐文章于 2023-01-06 08:57:24 发布