Tuesday, January 26, 2016

Swift: Display an alert

Swift
@IBOutlet weak var aButton: UIButton!

@IBAction func buttonTapped(sender : AnyObject){

let alertController = UIAlertController(title: "My alert", message:

"This is an alert!", preferredStyle: UIAlertControllerStyle.Alert)

alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default,handler: nil))

self.presentViewController(alertController, animated: true, completion: nil)
}