Skip to content

Commit

Permalink
Adds an alert view using the new alert controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Davies committed Aug 26, 2014
1 parent 92c507a commit 9a4e665
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 21-alerts-and-popovers/AppAlert/AppAlert/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ class ViewController: UIViewController, UIPopoverPresentationControllerDelegate
}

@IBAction func handleAlertPressed(sender: AnyObject) {
let alert = UIAlertController(title: "Alert", message: "Using the alert controller", preferredStyle: UIAlertControllerStyle.Alert)

let dismissHandler = {
(action: UIAlertAction!) in
self.dismissViewControllerAnimated(true, completion: nil)
}
alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: dismissHandler))
alert.addAction(UIAlertAction(title: "Delete", style: .Destructive, handler: dismissHandler))
alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: dismissHandler))
alert.addTextFieldWithConfigurationHandler { textField in
textField.placeholder = "Sample text field"
}
presentViewController(alert, animated: true, completion: nil)
}

@IBAction func handleActionSheetPressed(sender: AnyObject) {
Expand Down

0 comments on commit 9a4e665

Please sign in to comment.