Reputation: 23
I am trying to get image from camera or photo library and use an UIImageView
to preview that photo.
I use the code below to capture image :
let picker = UIImagePickerController()
picker.delegate = self
picker.sourceType = .camera
present(picker, animated: true, completion: nil)
and then I use this code to put image in imageView :
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
imageView.image = info[UIImagePickerControllerOriginalImage] as? UIImage
}
I get permission and the app load successfully on my IPhone but when I capture a picture it doesn't go back to main View to show on image view . and it crash . can any body help me ?
Upvotes: 1
Views: 3314
Reputation: 100541
You need to dismiss end of the function didFinishPickingMediaWithInfo
picker.dismiss(animated:true,completion:nil)
Upvotes: 1