Modal在Swift 3中弹出

时间:2017-04-12 12:55:32

标签: ios swift3 mobile-application

我想使用swift实现弹出模式。我必须实现这样,根据响应(是/否)我再次弹出一个,由用户点击。我如何实现这个? 任何帮助都会非常有用。

1 个答案:

答案 0 :(得分:4)

UIAlertController就是为此而设计的。

        let alertController = UIAlertController(title: "Default AlertController", message: "A standard alert", preferredStyle: .Alert)

        let cancelAction = UIAlertAction(title: "No", style: .Cancel) { (action:UIAlertAction!) in
            println("you have pressed the No button");
            //Call another alert here
        }
        alertController.addAction(cancelAction)

        let OKAction = UIAlertAction(title: "Yes", style: .Default) { (action:UIAlertAction!) in
            println("you have pressed Yes button");
            //Call another alert here
        }
        alertController.addAction(OKAction)

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