"Creating an image format with an unknown type is an error" with UIImagePickerController "Creating an image format with an unknown type is an error" with UIImagePickerController xcode xcode

"Creating an image format with an unknown type is an error" with UIImagePickerController


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


Below code did solve the problem:

If user perform changes to selected image pull only that image otherwise pull original image source without any changes and finally dismiss image picker view controller.

public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]){    if let image = info[UIImagePickerControllerEditedImage] as? UIImage {        imageView.image = image    }    else if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {        imageView.image = image    } else{        print("Something went wrong")    }    self.dismiss(animated: true, completion: nil)}