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...
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
}
}
In Swift3:
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
if picker.sourceType == .camera {
// Do something with an image from the camera
}
else {
// Do something with an image from another source
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With