我试图限制代码的显示,所以我只想调用包含两个字符串的函数来创建一个更快的快速1行而不是5/Swift:UIAlert in function - 使用未解析的标识符'present'
我越来越
使用未解决的标识符 '存在'
在行
错误存在(警报,动画:真,完成:无)
// Controlling Alerts for Errors
func showAlert(titleString: String, messageString: String) {
// Alert to go to Settings
let alert = UIAlertController(title: titleString, message: messageString, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Dismiss", style: .default, handler: { _ in
alert.dismiss(animated: true, completion: nil)
}))
self.present(alert, animated: true, completion: nil)
}
最常见的原因(我相信)是因为这个代码/函数不在'UIViewController'里面。是这样吗? – dfd
什么是“自我”?它需要是一个'UIViewController'。 – rmaddy
从哪里调用此片段? –