I need an instance of the root view controller.
I tried these approaches:
UIViewController *rootViewController = (UIViewController*)[[[UIApplication sharedApplication] keyWindow] rootViewController];
Returns: null :
Also, when I try to get an array of controllers:
NSArray *viewControllers = self.navigationController.viewControllers;
It returns only one controller, but it is not my root view controller.
If I try to take from the navigation controller:
UIViewController *root = (UIViewController*)[self.navigationController.viewControllers objectAtIndex:0];
Returns: null :
Any ideas why? What else can I try to get an instance of my root view controller?
Thank you
objective-c uiviewcontroller ios5 swift uinavigationcontroller
Streetboy Sep 14 2018-12-12T00: 00Z
source share