功能---彈出對話匡Alert
//設定一個alert的標題和訊息
var alert = UIAlertController(title: "完成", message: "成功", preferredStyle: UIAlertControllerStyle.Alert)
//增加一個alert按鈕
alert.addAction(UIAlertAction(title: “OK", style: UIAlertActionStyle.Default,handler: nil))
//讓alert呈現
self.presentViewController(alert, animated: true, completion: nil)
功能延伸---彈出對話匡Alert 消失後並產生動作
//設定一個alert的標題和訊息
var alert = UIAlertController(title: "完成", message: "恭喜得分", preferredStyle: UIAlertControllerStyle.Alert)
//增加一個alert按鈕,並且使他performSegue換到特定頁面
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler:
{(alert: UIAlertAction!) in self.performSegueWithIdentifier("to_record", sender: AnyObject?())}
))
{(alert: UIAlertAction!) in self.performSegueWithIdentifier("to_record", sender: AnyObject?())}
))
//讓alert呈現
self.presentViewController(alert, animated: true, completion: nil)