开发者

Retrieve the url of an image taken on the fly and saved in the gallery, how?

I allow the user to choose an image from the gallery or take a photo with the camera. I would to save the image path in both cases so that I can use it to display the image in a second moment.

When the user select an image from the gallery, I can use

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {


    if([[info valueForKey:@"UIImagePickerControllerMediaType"] isEqualToString:@"public.image"]) {
           NSURL *imageUrl = [info valueForKey:@"UIImagePickerControllerReferenceURL"];

}

}

Instead, if the user takes a photo on the fly, I save it in the photo roll with:

  UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

  UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);

After saving it, I would to retrieve the corresponding NSURL as the user had selected it.

How could I do?

EDIT

My problem isn't about the image chosen from the gallery. I succeed in retrieving the url using the UIImagePickerControllerReferenceURL path. My problem is when the user takes a photo with the camera. I can write it in the photo roll, but 开发者_如何学运维I should find a way to automatically select it such that

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 

is called again and I can use the UIImagePickerControllerReferenceURL key to retrieve the corresponding url.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜