Swift3处理alertviewcontroller ok和取消按钮

时间:2016-12-21 15:15:59

标签: swift3 xcode8

代码:

let alertController = UIAlertController(title: "StopRequest", message: msg, preferredStyle: .alert)

        let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (action:UIAlertAction!) in
        }
        alertController.addAction(cancelAction)

        let OKAction = UIAlertAction(title: "OK", style: .default) { (action:UIAlertAction!) in
        }
        alertController.addAction(OKAction)

        self.present(alertController, animated: true, completion:nil)

我在swift3中创建了一个UIAlertViewController。 Alertview工作正常。请帮我解决如何处理确定和取消事件。如果我们有多个警报如何区分它们?。提前谢谢

1 个答案:

答案 0 :(得分:0)

 let alert = UIAlertController(title: "Wrong Email Or Password", message: "Please Check Your Email or Password", preferredStyle: UIAlertControllerStyle.alert)


                    alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.default)
                    {
                        _ in  // add actions here

                        }
                    )
                    self.present(alert, animated: true, completion: nil)