UIImagePickerControllerEditedImage //无法使用索引类型为“UIImagePickerController.InfoKey”的类型'[String:Any]’下标
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { if let pickedImage = info[UIImagePickerControllerEditedImage] as? UIImage { self.userProfileImage.contentMode = .scaleAspectFit self.userProfileImage.image = pickedImage } picker.dismiss(animated: true, completion: nil) }方法签名已更改为
func imagePickerController(_ picker:UIImagePickerController,didFinishPickingMediaWithInfo info:[UIImagePickerController.InfoKey:Any])
您应该看到func名称的警告消息
Instance method
‘imagePickerController(:didFinishPickingMediaWithInfo:)’ nearly
matches optional requirement
‘imagePickerController(:didFinishPickingMediaWithInfo:)’ of protocol
‘UIImagePickerControllerDelegate’Candidate has non-matching type ‘(UIImagePickerController, [String :
Any]) -> ()’Move ‘imagePickerController(_:didFinishPickingMediaWithInfo:)’ to
another extension to silence this warningMake ‘imagePickerController(_:didFinishPickingMediaWithInfo:)’ private
to silence this warningRequirement ‘imagePickerController(_:didFinishPickingMediaWithInfo:)’ declared here (UIKit.UIImagePickerControllerDelegate)