简体   繁体   中英

Turning off Alert When Button Is Pressed Swift

I have alert view using this code:

func alert() {
    let alert = UIAlertController(title: "Time Is Up",
                                  message: "Either your company has Sold or had to Fold! (Click the button below to see)",
                                  preferredStyle: .alert)
    let action = UIAlertAction(title: "Next", style: .default) { _ in
        self.performSegue(withIdentifier: "congratsSegue", sender: nil)
    }

    alert.addAction(action)

    self.present(alert, animated: true, completion: nil)
}

I want to then turn this alert off when the done button pressed:

@IBAction func donePressed() {
}

Is this possible to do in Swift?

self.dismiss(animated: true, completion: nil)

I don't think you would want to do that, but you could I suppose. self here is the viewController.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM