Ios 如果要显示另一个警报控制器,请移除警报控制器
我的应用程序需要在不同的时间向用户显示一些信息。 我决定使用AlertController,但无法同时显示两个Alert Controller。 因此,我需要知道是否显示了警报控制器,关闭它并打开另一个 到目前为止我已经做到了。我正在使用self.presentedViewController检查AlertController是否显示。但我不知道如何关闭它。 我试过了Ios 如果要显示另一个警报控制器,请移除警报控制器,ios,swift,alert,uialertcontroller,Ios,Swift,Alert,Uialertcontroller,我的应用程序需要在不同的时间向用户显示一些信息。 我决定使用AlertController,但无法同时显示两个Alert Controller。 因此,我需要知道是否显示了警报控制器,关闭它并打开另一个 到目前为止我已经做到了。我正在使用self.presentedViewController检查AlertController是否显示。但我不知道如何关闭它。 我试过了 self.presentedViewController?.removeFromParentViewController()
self.presentedViewController?.removeFromParentViewController()
及
没有运气。有人能帮我吗?谢谢您只需在显示的
AlertController
上调用dismissViewControllerAnimated
。如果需要,可以在完成
块中显示下一个
self.alertViewController?.dismissViewControllerAnimated(true, completion: {
})
同一ViewController类提供的两个alertController?@SumitGarg是!但我对新的实现持开放态度,我刚刚写道:if self.presentedViewController!=nil{self.presentedViewController?.dismissViewControllerAnimated(true,完成:nil)}
self.alertViewController?.dismissViewControllerAnimated(true, completion: {
})