我将使用UIAlertController
,但是当我想提出它,我看到这个错误:使用未解决的标识符“存在”的 - 本方法不起作用了
use of unresolved identifier 'present'
这是我的代码:
func showAllert(title: String, msg: String, vc: UIViewController){
let alert = UIAlertController(title: title, message: msg, preferredStyle: .alert)
let action = UIAlertAction(title: "ok", style: .default, handler: nil)
alert.addAction(action)
present(alert, animated: true, completion: nil)
}
它在过去的工作对我来说!但现在它不是:( – Mehrdad
你必须在视图控制器上调用present,这个'showAllert'方法的类不是'UIViewController'类。 – rmaddy
谢谢你,你是对的:)) )@rmaddy – Mehrdad