首页 > 代码库 > UIAlertController的写法

UIAlertController的写法

UIAlertController的写法

by 伍雪颖

@IBAction func showAlert(sender: AnyObject) {
        let alertController = UIAlertController(title: "Default Style", message: "A standard alert.", preferredStyle: .Alert)
       
        let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) in
            
        }
        alertController.addAction(cancelAction)
       
        let destroyAction = UIAlertAction(title: "Destroy", style: .Destructive) { (action) in
            println(action)
        }
        alertController.addAction(destroyAction)
       
        let OKAction = UIAlertAction(title: "OK", style: .Default) { (action) in
            
        }
        alertController.addAction(OKAction)
       
        self.presentViewController(alertController, animated: true) {
            
        }
    }


UIAlertController的写法