Search code examples
uiimagepickercontroller

How can I tell if the image returned from didFinishPickingMediaWithInfo was from the camera or the photoalbum?


I have a view controller that needs to be able to choose a picture from the photo album and also from the camera. I can only have 1 delegate method for didFinishPickingMediaWithInfo and while I can tell if it's an image, I can't seem to tell if it's from the album or from the camera (and I need to save it in the album first). Is there anything in the info that can help me distinguish from the two?

Thanks...


Solution

  • Because the UIImagePickerController is passed to the method, all you have to do is:

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
      if ([picker sourceType] == UIImagePickerControllerSourceTypeCamera) {
        // Do something with an image from the camera
      } else {
        // Do something with an image from another source
      }
    }