我正在尝试将相机拍摄的图像保存到照片库中,并存储已保存图像的URL。我的代码:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
ALAssetsLibrary *library = [[ALAssetsLibrary alloc]init];
[library writeImageToSavedPhotosAlbum:(__bridge CGImageRef)([info objectForKey:UIImagePickerControllerOriginalImage])
orientation:ALAssetOrientationUp completionBlock:^(NSURL *assetURL, NSError *error) {
if(error == nil) {
_myImageUrl = [NSString stringWithFormat:@"%@",assetURL];
NSLog(@"%@",assetURL);
} else NSLog(@"%@",error);
}];
[picker dismissViewControllerAnimated:YES completion:nil];}
我的问题是assetUrl始终为空。有什么想法吗? 谢谢!