let alert = UIAlertController(title: "Alert Title", message: "This is an alert message.", preferredStyle: UIAlertControllerStyle.Alert) // Buttons for the alert let okButton = UIAlertAction(title: "OK", style: UIAlertActionStyle.Cancel, handler: nil) // Add button to alert alert.addAction(okButton) // Show alert presentViewController(alert, animated: true, completion: nil)
let alert = UIAlertController(title: "Delete User", message: "Are you sure you want to delete this user?", preferredStyle: UIAlertControllerStyle.Alert) let cancelButton = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil) let deleteButton = UIAlertAction(title: "Delete", style: UIAlertActionStyle.Destructive) { (UIAlertAction) in // Delete code here. } alert.addAction(cancelButton) alert.addAction(deleteButton) presentViewController(alert, animated: true, completion: nil)
(Swift 2.2)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.