小编典典

UIImagePickerController“创建未知类型的图像格式是错误”

swift

在iOS 10 Swift 3中从图像选择器中选择图像时,出现错误- 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)
}

没有选择和更新图像。我需要帮助或建议,以了解有关此方法的语法或任何内容在iOS10或Swift 3中是否已更改,或者是否有其他方法可以执行。


阅读 184

收藏
2020-07-07

共1个答案

小编典典

下面提到的代码确实为我解决了问题-

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)
}
2020-07-07