我正在努力弄清楚如何从 UIImagePickerControllerReferenceURL 获取图像(我知道我可以直接从中获取它,UIImagePickerControllerOriginalImage
但我有理由不想这样做)。这就是我所拥有的
/*
* Responds when an image is selected (from browsing)
*/
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [self obtainImageAtURLPath:[info objectForKey:UIImagePickerControllerReferenceURL]];
if(!image) return;
//...more code here
}
- (UIImage *) obtainImageAtURLPath:(NSURL *) urlPath
{
UIImage *image = [UIImage imageWithContentsOfFile:[urlPath path]];
return image;
}
但是,当我这样做时,我总是得到nil
而不是我的形象。urlPath 存在;但是,它不想转换为 UIImage。请帮忙。
如果我打印出来,NSLog(@"%@", urlPath)
我会得到assets-library://asset/asset.JPG?id=53784678-BD17-4EE4-9A96-601B81012AFE&ext=JPG
如果我打印出来,NSLog(@"%@", [urlPath path])
我会得到/asset.JPG
.