My app needs to show some info to the user at different times. I decided to use AlertControllers but I cannot display two Alert Controllers at the same time. Thus I need to know if an Alert Controller is shown, close it and open another one.
I've done this so far. I'm using self.presentedViewController
to check is the AlertController is shown or not. But I cannot figure out how to close it.
I tried with
self.presentedViewController?.removeFromParentViewController()
and
self.presentedViewController?.delete(self.presentedViewController)
with no luck. Someone can help me? Thanks
You can just call dismissViewControllerAnimated
on the presented AlertController
. You can present the next one in the completion
block if you want.
self.alertViewController?.dismissViewControllerAnimated(true, completion: {
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With