对于我正在开发的应用程序,我使用UIImagePickerController拍摄照片并将其存储在相机胶卷中:
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info {
//... some stuff ...
UIImageWriteToSavedPhotosAlbum([info objectForKey:@"UIImagePickerControllerOriginalImage"], nil, nil, nil);
}
图像已保存,现在我需要获取其参考网址,因此我尝试枚举相机胶卷并获取最后一张图像,但我总是在拍摄之前得到图像。
任何人都知道如何获得刚刚保存的图片的参考资料?
谢谢, 最大
答案 0 :(得分:12)
此解决方案应解决问题:
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeImageToSavedPhotosAlbum:((UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage]).CGImage
metadata:[info objectForKey:UIImagePickerControllerMediaMetadata]
completionBlock:^(NSURL *assetURL, NSError *error) {
NSLog(@"assetURL %@", assetURL);
}];
et voila:
assetURL assets-library://asset/asset.JPG?id=1611E84C-24E2-4177-B49A-1C57B4A9C665&ext=JPG