目前,UIImage保存到系统相册主要有两种方式:
方式一:(就一句话)
UIImageWriteToSavedPhotosAlbum(img,self, @selector(image:didFinishSavingWithError:contextInfo:),nil);
然后实现回调:
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
if (!error) {
//保存成功
}else {
//保存失败
}
}方式二:AssertsLibrary
ALAuthorizationStatus auth = [ALAssetsLibrary authorizationStatus];
if (auth == ALAuthorizationStatusRestricted || auth == ALAuthorizationStatusDenied){
//无权限
return ;
}
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeImageDataToSavedPhotosAlbum:UIImageJPEGRepresentation(img, 1) metadata:nil completionBlock:^(NSURL *assetURL, NSError *error) {
}];本文出自 “Layne的学习园地” 博客,请务必保留此出处http://laynestone.blog.51cto.com/9459455/1794951
原文地址:http://laynestone.blog.51cto.com/9459455/1794951