Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIImagePickerController exception : "Source type must be UIImagePickerControllerSourceTypeCamera"

what is wrong with this? I really don't understand some important parts for UIImagePickerController....

here's the source:

     UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;        
imagePickerController.delegate = self;
[self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];

Can't I open the photo library? Any help appreciated!

like image 723
Danail Avatar asked Sep 11 '10 12:09

Danail


2 Answers

If you're using the photo library, do you need to set cameraCaptureMode?

like image 129
nevan king Avatar answered Oct 18 '22 04:10

nevan king


Maybe not in your case but when you initalize your UIImagePickerController object, FIRST you need to set your source type before setting any other properties otherwise you get the same error.

let imagePickerController =  UIImagePickerController()
imagePickerController.sourceType = UIImagePickerControllerSourceType.Camera
imagePickerController.cameraCaptureMode =   
UIImagePickerControllerCameraCaptureMode.Photo
imagePickerController.cameraDevice = .Front
imagePickerController.showsCameraControls = true;
imagePickerController.navigationBarHidden = false;
imagePickerController.toolbarHidden = false;
imagePickerController.delegate = self
like image 20
Ilker Baltaci Avatar answered Oct 18 '22 05:10

Ilker Baltaci