我遇到过以下错误代码:Creating an image format with an unknown type is an error
。我已经看过几个关于这个的线索,但似乎没有人在我的情况下解决这个问题。这里我做错了什么是我的代码
public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
let data = UIImagePNGRepresentation(image)
} else{
print("Something went wrong")
}
}
答案 0 :(得分:-2)
这可能是因为你没有打开可选项。
尝试更改此行:
let data = UIImagePNGRepresentation(image)
要强>
let data = UIImagePNGRepresentation(image!)
希望它有所帮助。