图像选择器不会选择图像

时间:2017-05-27 06:27:57

标签: ios swift xcode uicollectionview uiimagepickercontroller

编辑:我看过其他答案,但他们没有解决我的问题。我的问题是图像的信息应该打印到控制台,但不打印。

我的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

我到处寻找答案,但没有任何效果。我在代码中遗漏了什么吗?

0 个答案:

没有答案