error: Cannot subscript a value of type '[String : Any]' with an index of type 'UIImagePickerController.InfoKey' [duplicate]

喜夏-厌秋 提交于 2019-12-01 21:29:40

It appears you are using Xcode 10/iOS 12. The signature of the delegate method changed.

Use UIImagePickerController.InfoKey instead of String for the info keys.

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any])

And then use .originalImage instead of UIImagePickerControllerOriginalImage.

extension ImageClassificationViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
        picker.dismiss(animated: true)

        let image = info[.originalImage] as! UIImage
        imageView.image = image
        updateClassifications(for: image)
    }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!