Swift中如何在Alert弹窗弹出后将其关闭?
Swift 5/iOS 15 实现Alert弹窗自动关闭的最简方法
我需要实现一个能自动关闭的简单Alert弹窗,当前弹窗通过以下代码展示:
present(alert, animated: true, completion: nil)
已找到适配Swift 5/iOS 15环境的最简解决方案,分享给有相同需求的开发者:
// 2秒后自动关闭弹窗 DispatchQueue.main.asyncAfter(deadline: .now() + 2.0, execute: { alert.dismiss(animated: true, completion: nil) })
内容的提问来源于stack exchange,提问作者Lionel Yu
相关产品推荐
相关产品推荐

