MichaelQ MichaelQ - 5 months ago 22
iOS Question

UIAlertController not showing

I'm trying to display a message to my users with alert controller but it wont show

let alert = UIAlertController(title: "Error", message: "Incorrect username/password", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "okay", style: UIAlertActionStyle.Default, handler: nil))

Answer

looks like you haven't presented it yet. paste this code where you want to show the alert

self.presentViewController(alert, animated: true, completion: nil)