Jonathan Smith
Jonathan Smith

Reputation: 2599

UIImagePickerControllerMediaURL always nil for a photo

I am having trouble getting the image URL for a photo that my app takes using a UIImagePickerController. If a video is captured, the dictionary object returned in didFinishPickingMediaWithInfo contains a UIImagePickerControllerMediaURL value which points to the video file.

If i take a photo, the dictionary object does not contain a UIImagePickerControllerMediaURL value, or a UIImagePickerControllerReferenceURL value.

Googling around has thrown up different things, which i have tried without success, including:

But the info dictionary never contains a URL to the image. Any ideas?

Upvotes: 0

Views: 3239

Answers (2)

Andrew Tetlaw
Andrew Tetlaw

Reputation: 2689

Some extra info relating to your question:

The UIImagePickerControllerReferenceURL value is set only if the image is edited. This key then hold the URL to the original image. From the documentation:

The Assets Library URL for the original version of the picked item. After the user edits a picked item—such as by cropping an image or trimming a movie—the URL continues to point to the original version of the picked item.

Upvotes: 2

SAE
SAE

Reputation: 1739

As stated in the documentation, info is:

A dictionary containing the original image and the edited image, if an image was picked; or a filesystem URL for the movie, if a movie was picked. The dictionary also contains any relevant editing information.

So you don't get an URL if an image has been picked. You get the image as an UIImage.

// Get picked image from info dictionary

UIImage *image = info[UIImagePickerControllerOriginalImage];

[save the image]

Upvotes: 2

Related Questions