Can';t向UIAlertController(Swift)添加警报操作
我正在尝试向UI警报添加“确定”按钮,但无法使用alertController.addAction添加该按钮 在这种情况下我该怎么办 提前谢谢Can';t向UIAlertController(Swift)添加警报操作,swift,alert,uialertcontroller,uialertaction,Swift,Alert,Uialertcontroller,Uialertaction,我正在尝试向UI警报添加“确定”按钮,但无法使用alertController.addAction添加该按钮 在这种情况下我该怎么办 提前谢谢 if error == nil { let alert: UIAlertController = UIAlertController(title: "Account Created", message: "Please confirm your email", preferredStyle: .Alert)
if error == nil {
let alert: UIAlertController = UIAlertController(title: "Account Created", message: "Please confirm your email", preferredStyle: .Alert)
let okButton = UIAlertAction(title: "Ok", style: .Default) { action -> Void in
self.performSegueWithIdentifier("toMain", sender: self)
alertController.addAction(okButton)
self.presentViewController(alert, animated: true, completion: nil)
}
} else {
println("\(error)")
}
警报
而不是警报控制器
alert.addAction
应该在您的ok按钮
操作之外if error == nil {
let alert: UIAlertController = UIAlertController(title: "Account Created", message: "Please confirm your email", preferredStyle: .Alert)
let okButton = UIAlertAction(title: "Ok", style: .Default) { action -> Void in
self.performSegueWithIdentifier("toMain", sender: self)
}
alert.addAction(okButton)
self.presentViewController(alert, animated: true, completion: nil)
} else {
println("\(error)")
}
它的alert.addaction..不是alertcontroller