I am wondering, that how to get navController from AppDelegate = [[UIApplication sharedApplication] delegate] in the iPhone programming. e.g., in other viewController where we reference to the AppDelegate.
In the applicationDelegate.h we have:
UINavigationController *navController;
And the following in applicationDelegate.m
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview: navController.view];
[window makeKeyAndVisible];
}
Is there anyway to get the navController from the mainWindow:
UIWindow *mainWindow = [appDelegate window];
If this other UIViewController is contained in the UINavigationController, you can simply call:
from the UIViewController.
Otherwise, you can set UINavigationController as a property in the AppDelegate.
Then access
appDelegate.navController.Or, you can set the UINavigationController as window’s rootViewController:
And call from anywhere: