imagePickerController didFinishPickingMediaWithInfo用法

时间:2017-06-13 08:06:25

标签: ios swift

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

为什么呢?以及如何使用它?

1 个答案:

答案 0 :(得分:1)

info[UIImagePickerControllerOriginalImage] as? UIImage

info是字典,这是一个集合,其元素是键值对。

此处为字符串类型键: - UIImagePickerControllerOriginalImage

值为: - UIImage对象

此外,您可以在此处看到所有密钥https://developer.apple.com/documentation/uikit/uiimagepickercontrollerdelegate/editing_information_keys