我正在尝试在新的 Xcode 更新 8.3.2 中做简单的警报我在显示警报对话框时遇到问题:
@IBAction func testButonAlert()
{
let alertAction = UIAlertAction( title : "Hi TEst" ,
style : UIAlertActionStyle.destructive,
handler : { ( UIAlertActionStyle) -> Void in print("") })
self.present(alertAction , animated: false, completion: nil)
}
错误:
Cannot convert value of type 'UIAlertAction' to expected argument type 'UIViewController'
最佳答案
你应该使用 UIAlertController。
let alertVC = UIAlertController(title: "title", message: "message", preferredStyle: .alert)
alertVC.addAction(UIAlertAction(title: "Close", style: .default, handler: nil))
self.present(alertVC, animated: true, completion: nil)
关于swift - 无法将类型 'UIAlertAction' 的值转换为预期的参数类型 'UIViewController'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43656480/