【Swift】UIImagePickerControllerOriginalImage で エラー

↓こんな感じのエラーが出た時は、

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

teratail.com

NG

private func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
let image = info[UIImagePickerControllerOriginalImage] as! UIImage

OK

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let image = info[.originalImage] as! UIImage

返信を残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

CAPTCHA