Home>

No alert is displayed when opening the app. Please tell me the cause. Please.

override func viewDidLoad () {
        super.viewDidLoad ()
        alert ()
    }
func alert () {
        let alert: UIAlertController = UIAlertController (title: "Who are you?", message: "Please select", preferredStyle: UIAlertController.Style.alert)
        let appleButton: UIAlertAction = UIAlertAction (title: "apple", style: UIAlertAction.Style.default, handler: {
            (action: UIAlertAction!)->Void in
            print ("OK")
        })
        let orangeButton: UIAlertAction = UIAlertAction (title: "Orange", style: UIAlertAction.Style.default, handler: {
            (action: UIAlertAction!)->Void in
            print ("Cancel")
        })
        // Button added
        alert.addAction (appleButton)
        alert.addAction (orangeButton)
        // Display Alert
        present (alert, animated: true, completion: nil)
    }
Trends