3

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.

Sefran
  • 375
  • 6
  • 24
  • 1
    The question with the answer is here: http://stackoverflow.com/questions/4457904/iphone-how-do-i-get-the-file-path-of-an-image-saved-with-uiimagewritetosavedphot :) – Lachezar Todorov Aug 09 '11 at 09:48
  • @Lachezar Todorov: I had to maintain the compatibility with 3.1 iOS, anyway, I'll consider it for the future. Thank you very much. – Sefran Aug 24 '11 at 19:29
  • I hope this would be help you. http://stackoverflow.com/questions/3922520/path-and-extension-of-image – sandy May 11 '11 at 09:57
  • 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. – Sefran May 11 '11 at 10:04
  • do you mean automatically selecting the previous image that was taken and saved – visakh7 May 11 '11 at 10:09
  • @7KV7: Yes. By my app, the user takes the photo. When the user clicks on the "use" button I save it in the photo roll. Then I would to retrieve the corresponding url as the user had selected it from the gallery. – Sefran May 11 '11 at 10:16

0 Answers0