Most of the mobile apps will be having an alert to show different kinds of messages such as to show offers, report errors, to remind about empty text fields and etc.. In this tutorial youre gonna learn how to show alert in your ios app using swift.
In the below code replace 'TITLE' with your alert box title and 'DESCRIPTION' with your alert message.Also you could add your custom code to be executed when the user presses the 'OK' button.
Swift:
Swift:
let myAlert = UIAlertController(title: "TITLE", message: "DESCRIPTION", preferredStyle: .Alert)
var actionOnOk = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) {
UIAlertAction in
//add your code here to execute while clicking ok button
}
myAlert.addAction(actionOnOk)
self.presentViewController(myAlert, animated: true, completion: nil)
No comments:
Post a Comment