To show an alert in Swift programming language, you need to first import the UIKit framework then use UIAlertController object.
A UIAlertController object displays an alert message to the user.
Important: UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated.) To create and manage alerts in iOS 8 and later, instead use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert.
Example:
var MyAlert = UIAlertController(title: "My Alert Box", message: "Hi", preferredStyle: UIAlertControllerStyle.Alert)
var MyOkayAction = UIAlertAction(title: "Okay", style: UIAlertActionStyle.Default, handler: nil)
MyAlert.addAction(MyOkayAction)
self.presentViewController(MyAlert, animated: true, completion: nil)
0 Comment(s)