i'm trying to open the movie's gallery on ipad, but I have this error and i don't know why.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Source type must be UIImagePickerControllerSourceTypeCamera'
This is my code:
func GaleriaVideo() {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.SavedPhotosAlbum) {
println("Galeria Video")
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum
imagePicker.mediaTypes = [kUTTypeMovie]
imagePicker.allowsEditing = false
imagePicker.showsCameraControls = false
imagePicker.modalPresentationStyle = .Custom
self.presentViewController(self.imagePicker, animated: true, completion: nil)
}
}
Similar code works for me to photo gallery, but i don't know why this not works.
Can you tell me what's wrong in my code, or what i have to search to do this? i'm trying this for few days ago and i'm feel lost.
Thanks you,
EDIT:
This is my Photo gallery and it works:
func GaleriaImagen() {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.SavedPhotosAlbum){
println("Galeria Imagen")
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum
imagePicker.allowsEditing = false
imagePicker.modalPresentationStyle = .Custom
self.presentViewController(self.imagePicker, animated: true, completion: nil)
}
}
func imagePickerControllerDidCancel(picker: UIImagePickerController!) {
self.dismissViewControllerAnimated(false, completion: nil)
}
func imagePickerController(picker: UIImagePickerController!, didFinishPickingImage image: UIImage!, editingInfo: NSDictionary!) {
self.dismissViewControllerAnimated(true, completion: nil)
}
Add:
UINavigationControllerDelegate, UIImagePickerControllerDelegate