func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let image = (info[UIImagePickerControllerOriginalImage] as? UIImage) {
self.memeImage.image = image
}
dismiss(animated: true, completion: nil)
}
info
是一个包含两个值的字典。但在:
info[UIImagePickerControllerOriginalImage] as? UIImage
其中只有一个字符串值UIImagePickerControllerOriginalImage
。
为什么呢?以及如何使用它?
答案 0 :(得分:1)
info[UIImagePickerControllerOriginalImage] as? UIImage
info
是字典,这是一个集合,其元素是键值对。
此处为字符串类型键: - UIImagePickerControllerOriginalImage
值为: - UIImage
对象
此外,您可以在此处看到所有密钥: https://developer.apple.com/documentation/uikit/uiimagepickercontrollerdelegate/editing_information_keys