我使用此代码提供警报视图:
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中完成吗?
答案 0 :(得分:1)
self.dismiss(animated: true, completion: nil)
我认为你不想这样做,但我想你可以。 self
这里是viewController。