用Block打印警告:
ALAssetsLibrary *assetsLibrary=[[ALAssetsLibrary
alloc]init];
[assetsLibrary
writeImageToSavedPhotosAlbum:[image
CGImage]
orientation:(ALAssetOrientation)[image
imageOrientation]
completionBlock:^(NSURL
*assetURL,
NSError
*error)
{
if
(error) {
NSLog(@"Save
image fail:%@",error);
}else{
NSLog(@"Save
image succeed.");
}
}];
打印结果:
Save image fail:Error
Domain=ALAssetsLibraryErrorDomain Code=-3311 "User denied access"
UserInfo=0x14dc9660 {NSLocalizedDescription=User denied access,
NSUnderlyingError=0x14db5200 "The operation couldn’t be completed.
(ALAssetsLibraryErrorDomain error -3311.)",
NSLocalizedFailureReason=The user has denied the application access
to their media.}
原因是程序没用获取到用户权限,可以在"设置-隐私-照片\"选项中,允许应用访问你的手机相册。
加载中,请稍候......