Swift: How to make a UIAlertController
All apps have to interact with a user at one time or another. Ever since Swift 3, app developers must use the UIAlertController to accomplish this. Here’s an example of one that I use in my apps:
Thank you for reading this post, don't forget to subscribe!
let title = “Pop-up Message Example”
let message = “This is an example of a pop-up message in Swift.”
let button = “Close”
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: button, style: UIAlertAction.Style.default, handler: {(action:UIAlertAction!) in
}))
self.present(alert, animated: true, completion: nil)
}
When I make an UIAlertController, I like to organize it so I can quickly look at a block of code. This example will show a pop-up window with the title “Pop-up Message Example” and then show a message under it.
For more information about UIAlertController, click here.
Do you have questions? Please ask them below.
About Post Author
Discover more from CompuScoop.com
Subscribe to get the latest posts sent to your email.