Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove an Alert Controller if another Alert Controller is called to be shown

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

like image 255
Nicholas Avatar asked Jan 15 '15 13:01

Nicholas


1 Answers

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: {

 })
like image 110
rakeshbs Avatar answered Sep 19 '22 12:09

rakeshbs