ios – 无法调用非函数类型的值“UIViewController?”

ios – 无法调用非函数类型的值“UIViewController?”,第1张

概述我想创建一个警告对话框,显示消息,这是我在ViewController. swift中的代码: func showErrorAlert(title: String , msg: String){ let alert = UIAlertController(title: title, message: msg, preferredStyle: .Alert) let action = 我想创建一个警告对话框,显示消息,这是我在VIEwController. swift中的代码:

func showErrorAlert(Title: String,msg: String){    let alert = UIAlertController(Title: Title,message: msg,preferredStyle: .Alert)    let action = UIAlertAction(Title: "OK",style: .Default,handler: nil)    alert.addAction(action)    presentedVIEwController(alert,animated: true,completion: nil)}

最后一行给我一个错误:

“Cannot call value of non-function type “UIVIEwController?””

解决方法 编辑:
对于Swift 3,将其更改为

present(alert,animated: false,completion: nil)

调用了错误的功能.

应该

presentVIEwController(alert,completion: nil)

而不是presentVIEwController(alert,animated:true,completion:nil)

总结

以上是内存溢出为你收集整理的ios – 无法调用非函数类型的值“UIViewController?”全部内容,希望文章能够帮你解决ios – 无法调用非函数类型的值“UIViewController?”所遇到的程序开发问题。

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

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

原文地址: https://outofmemory.cn/web/1005670.html

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

发表评论

登录后才能评论

评论列表(0条)

保存