小编dro*_*ati的帖子

无法下标类型'[String:Any]'的值,其索引类型为'UIImagePickerController.InfoKey'

我正在使用Apple的Swift iOS教程.这是一个错误,

无法下标类型'[String:Any]'的值,其索引类型为'UIImagePickerController.InfoKey'

他们定义的功能如下.

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

    // The info dictionary may contain multiple representations of the image. You want to use the original.
    guard let selectedImage = info[UIImagePickerControllerOriginalImage] as? UIImage else {
        fatalError("Expected a dictionary containing an image, but was provided the following: \(info)")
    }

    // Set photoImageView to display the selected image.
    photoImageView.image = selectedImage

    // Dismiss the picker.
    dismiss(animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

我正在使用Xcode Version 10.0 beta 3,其中包括Swift …

uiimagepickercontroller ios swift

46
推荐指数
5
解决办法
3万
查看次数

标签 统计

ios ×1

swift ×1

uiimagepickercontroller ×1