UIImagePickerController crashes when video button is tapped

Following code works good when capturing photo using camera, but app crashes when user taps on video.


let imagePicker = UIImagePickerController()
imagePicker.modalPresentationStyle = .currentContext
imagePicker.delegate = self
if let _ = UIImagePickerController.availableMediaTypes(for: .camera) {
     imagePicker.mediaTypes = UIImagePickerController.availableMediaTypes(for: .camera)!
     if UIImagePickerController.isSourceTypeAvailable(.camera) {
         imagePicker.sourceType = .camera
         present(imagePicker, animated: true, completion: nil)
     }
}

Replies

Did you solve your issue? Looks like I have the same problem.