我的imagePicker无法正常工作。这是我用来设置它的代码:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
print(info)
picker.delegate = self
var selectedImageFromPicker: UIImage?
if let editedImage = info["UIImagePickerControllerEditedImage"] {
selectedImageFromPicker = editedImage as? UIImage
} else if let originalImage = info["UIImagePickerControllerOriginalImage"] {
selectedImageFromPicker = originalImage as? UIImage
}
if let selectedImage = selectedImageFromPicker {
logoImageView.image = selectedImage
}
}
当呈现选择器并且我选择图像时,不会打印(信息)并且编译器会抛出此错误:
[Generic] Creating an image format with an unknown type is an error
我到处寻找答案,但没有任何效果。我在代码中遗漏了什么吗?