What you're looking for is presentedViewController
:
UIViewController *vc = self.window.rootViewController.presentedViewController;
Question
I am trying to access a view in my AppDelegate.m. I was using self.window.rootViewController
to get a reference to the active ViewController however, when I create a modal view with presentViewController
I am unable to access the newly presented view. How do I obtain a reference to a modal view from the AppDelegate.m?
Solution
What you're looking for is presentedViewController
:
UIViewController *vc = self.window.rootViewController.presentedViewController;
OTHER TIPS
If the modal view controller was presented off the rootViewController, than you should be able to access it with the following command:
NSArray *childVCs = [self.window.rootViewController childViewControllers];
Your modal viewController will be one of the objects in that array.