A
A
Alexander Krupnov2019-11-19 12:54:18
Swift
Alexander Krupnov, 2019-11-19 12:54:18

I get the error "UIImage? is not convetrible to UIImage". How to work with UIImagePickerController in Swift 5?

I get this error "UIImage? is not convetrible to UIImage" in this line "if let possibleImage = info[.editedImage] as? UIImage {". Interested in swift 5.

private func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
        var newImage: UIImage

        if let possibleImage = info[.editedImage] as? UIImage {
            newImage = possibleImage
        } else if let possibleImage = info[.originalImage] as? UIImage {
            newImage = possibleImage
        } else {
            return
        }

        // do something interesting here!
        print(newImage.size)

        dismiss(animated: true)
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
briahas, 2019-11-19
@briahas

Try brackets aroundinfo[.editedImage] as? UIImage

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question