While choosing an image from the image picker in iOS 10 Swift 3 I am getting an error - Creating an image format with an unknown type is an error
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) { imagePost.image = image self.dismiss(animated: true, completion: nil) }
The image is not getting selected and updated. I need help or suggestion to know if the syntax or anything regarding this method has been changed in iOS10 or Swift 3 or is there any other way to do this.
Below mentioned code did solve the problem for me -
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) { if let image = info[UIImagePickerControllerOriginalImage] as? UIImage { imagePost.image = image } else{ print("Something went wrong") } self.dismiss(animated: true, completion: nil) }
Remember to add delegate to self
let picker = UIImagePickerController() picker.delegate = self // delegate added
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