I have a UIImagePickerViewerController. It works perfectly when I select UIImagePickerControllerSourceTypeCamera
. However, when I go try to select UIImagePickerControllerSourceTypeSavedPhotosAlbum
, it crashes with this error:
2011-09-14 01:41:21.779 NG911[378:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Source type must be UIImagePickerControllerSourceTypeCamera'
Here is the code I have:
if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum] || ![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
UIAlertView *noCameraAlert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"This device does not support a photo library"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[noCameraAlert setTag:2];
[noCameraAlert show];
[noCameraAlert release];
return;
}
[picker setSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum];
[picker setShowsCameraControls:YES];
[picker setAllowsEditing:NO];
[self presentModalViewController:picker animated:YES];
Any help is greatly appreciated! Thanks in advance!
Your mistake is in this line
[picker setShowsCameraControls:YES];
which is where the exception is thrown, the problem is you cannot set showCameraControls to yes when you are using the album. Just comment that line out and you should be fine.
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