tardoandre tardoandre - 3 months ago 10
iOS Question

Why is my UIAlertController not being fired?

I want to display a

UIAlertController
whenever user opens the application.

This is how I'm creating and trying to show it:

import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

//simple alert dialog
let alert=UIAlertController(title: "Alert 1", message: "One is awesome", preferredStyle: UIAlertControllerStyle.Alert);
//show it
showViewController(alert, sender: self);

}
}


Why is it not being displayed?

Answer

It will work if you'd use: presentViewController(alert, animated: true, completion: nil)

Comments