Nitin
Nitin

Reputation: 63

How to dismiss a presented UIAlertController before displaying another in Objective C

I want to dismiss the UIAlertControllers that were previously presented before presenting a new UIAlertController. I need to do this from the AppDelegate. How can this be done. All suggestions are welcome.

Upvotes: 3

Views: 1434

Answers (2)

katleta3000
katleta3000

Reputation: 2494

This should help, you can expand it to the cycle for all view controllers and views:

[[UIApplication sharedApplication].keyWindow.rootViewController.view endEditing:YES];

Upvotes: 0

Fennelouski
Fennelouski

Reputation: 2431

You could find the top presented view controller and check to see if it's a UIAlertController. If it is, then you could call dismissViewControllerAnimated: on it. All of this could be done pretty simply from the app delegate.

Upvotes: 4

Related Questions