Swift 4.2 imagePickerController问题

Swift 4.2 imagePickerController问题,第1张

概述试图将聊天客户端从 swift 4传递到 swift 4.2并且使用选择器我发现了麻烦. UIImagePickerControllerEditedImage //无法使用索引类型为“UIImagePickerController.InfoKey”的类型'[String:Any]’下标 func imagePickerController(_ picker: UIImagePickerContro 试图将聊天客户端从 swift 4传递到 swift 4.2并且使用选择器我发现了麻烦.

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 warning

Make ‘imagePickerController(_:dIDFinishPickingMediawithInfo:)’ private
to silence this warning

Requirement ‘imagePickerController(_:dIDFinishPickingMediawithInfo:)’ declared here (UIKit.UIImagePickerControllerDelegate)

总结

以上是内存溢出为你收集整理的Swift 4.2 imagePickerController问题全部内容,希望文章能够帮你解决Swift 4.2 imagePickerController问题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/999923.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存