簡體   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