“创建具有未知类型的图像格式是错误的”使用UIImagePickerController [英] "Creating an image format with an unknown type is an error" with UIImagePickerController

查看:265
本文介绍了“创建具有未知类型的图像格式是错误的”使用UIImagePickerController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从iOS 10 Swift 3中的图像选择器中选择图像时出现错误 - 创建包含未知类型的图像格式是错误

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

图像未被选中和更新。我需要帮助或建议才能知道在iOS10或Swift 3中是否更改了此方法的语法或任何内容,或者是否有其他方法可以执行此操作。

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

这篇关于“创建具有未知类型的图像格式是错误的”使用UIImagePickerController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆