繁体   English   中英

快速按下按钮时关闭警报

[英]Turning off Alert When Button Is Pressed Swift

我有使用以下代码的警报视图:

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)
}

我想在按下完成按钮时关闭此警报:

@IBAction func donePressed() {
}

在Swift中可以做到吗?

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

我不希望您这样做,但我可以。 这里的self是viewController。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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