当按钮被快速按下时关闭警报

时间:2017-08-08 17:55:44

标签: ios swift uialertcontroller

我使用此代码提供警报视图:

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中完成吗?

1 个答案:

答案 0 :(得分:1)

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

我认为你不想这样做,但我想你可以。 self这里是viewController。