UINavigationController topViewController
@property(nonatomic, readonly, retain) UIViewController *topViewController
UINavigationController topViewController example.
- (void)applicationDidFinishLaunching:(UIApplication *)application {
RootViewController *rootViewController = (RootViewController *)[navigationController topViewController];
rootViewController.managedObjectContext = self.managedObjectContext;
// Configure and show the window
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}
RootViewController *rootViewController = (RootViewController *)[navigationController topViewController];
rootViewController.managedObjectContext = self.managedObjectContext;
// Configure and show the window
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}
Example of [UINavigationController topViewController].
Try topViewController instead of visibleViewController.
FirstViewController *fVC = [navController topViewController];
FirstViewController *fVC = [navController topViewController];
UINavigationController topViewController example.
Implement the UINavigationControllerDelegate method:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
and query it to find out the currently displayed view controller:
navigationController.topViewController
This is the one you're coming from.
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
and query it to find out the currently displayed view controller:
navigationController.topViewController
This is the one you're coming from.