Tuesday, May 17, 2016

Alerts

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.

SwiftUI Search & Filter with Combine - Part 3 (iOS, Xcode 13, SwiftUI, 2...

In part 3 of the Searchable video series, I show you how to use Combine in #SwiftUI for the search and filter logic connected to the searcha...