ios - 如果调用另一个 Alert Controller 以显示,则删除 Alert Controller

标签 ios swift alert uialertcontroller

我的应用需要在不同时间向用户显示一些信息。 我决定使用 AlertControllers 但我不能同时显示两个 Alert Controllers。 因此我需要知道是否显示了警报 Controller ,关闭它并打开另一个。

到目前为止我已经做到了。我正在使用 self.presentedViewController 检查是否显示了 AlertController。但我不知道如何关闭它。 我试过

self.presentedViewController?.removeFromParentViewController()

self.presentedViewController?.delete(self.presentedViewController)

运气不好。有人可以帮助我吗?谢谢

最佳答案

您可以在呈现的 AlertController 上调用 dismissViewControllerAnimated。如果需要,您可以在 completion block 中显示下一个。

self.alertViewController?.dismissViewControllerAnimated(true, completion: {

 })

关于ios - 如果调用另一个 Alert Controller 以显示,则删除 Alert Controller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27964236/

相关文章:

iOS 表格 View 单元格未调整大小

ios - swift 3 : Swipe to 'Flag' , 如何

arrays - 按类型过滤 Swift [AnyObject] 数组

ios - 使用通用链接时隐藏 "Open in app"横幅

ios - 如何在IOS中同时发送N个请求

javascript - 在 WebkitView 中注入(inject) JavaScript 以监听文档正文以查找不适用于所有网页的任何点击事件

swift - 获取放置的 SCNNode 的世界 x、y 和 z - Swift

selenium - 如何使用 WebDriver 检查警报是否存在?

swift - 为什么我的 UIAlert 上的按钮重复?

Javascript 警报不适用于按钮单击