本文介绍了在相机胶卷中保存图像并获取资产网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于我正在开发的应用,我使用UIImagePickerController拍摄照片并将其存储在相机胶卷中:
for an app I'm developing, I use UIImagePickerController to shoot a picture and store it in camera roll:
- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info {
//... some stuff ...
UIImageWriteToSavedPhotosAlbum([info objectForKey:@"UIImagePickerControllerOriginalImage"], nil, nil, nil);
}
保存图像,现在我需要获取它的参考url所以我尝试枚举相机胶卷并获取最后一张图片,但我总是在拍摄之前得到图像。
the image is saved, now I need to get its reference url so I try to enumerate camera roll and get the last image, but I always get the image before the one I just shot.
任何人都知道如何获得刚刚保存的图片的参考?
Anybody has an idea how to get the reference of the just saved picture?
谢谢,
Max
Thanks,Max
推荐答案
此解决方案应解决问题:
This solution should fix the problem:
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
这篇关于在相机胶卷中保存图像并获取资产网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!