I need to check if there is still a modal view over the root view controller.
The problem I am facing is that I have a second modal view coming from some thread that needs to be displayed. I want to delay the second modal view until the first one is gone.
I cannot just launch it after the first is dismissed because the second modal view is conditional.
[self.window.rootViewController presentModalViewController:vc animated:YES];
What I want to do (feel free to suggest a better alternative way):
- Check if
self.window.rootViewControllercurrently has a modal view displayed on top (or is still animating modal view). - use
performSelector:afterDelay:0.1 - Check again, and if needed, delay again
Get
rootViewController.presentedViewController(available in iOS 5.0+) orrootViewController.modalViewController(available in iOS 2.0+) and see if it’s nil.Also, you don’t want to present the second view controller from the secondary thread, all UI stuff has to be done on the main thread.