Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the 'current' navigation controller from tab bar controller

Is there is a method to retrieve tab bar controller's current visible navigation controller?

For example, I have 2 tabbars in my program (one navigation controller each) as below

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
{   
   //Method is called when user clicks on a hyperlink in one of view controllers
    NSDictionary *dict = [self parseQueryString:[url query]];
    NSString *userID = [dict objectForKey:@"id"];
    NSString *navconTitle = [dict objectForKey:@"navcon"];


    //intention is to push a view controller onto the CURRENT navigation stack
    [navcon pushViewController:someViewController animated:YES];

    }
}

return YES;
}

Can anyone advise me how I can determine the current navigation controller so that I can push more viewcontrollers onto it?

like image 509
Zhen Avatar asked Jun 22 '11 14:06

Zhen


1 Answers

Use the UITabBarControllers selectedViewController property.

navcon = (UINavigationController*)myTabBarController.selectedViewController;
[navcon pushViewController:someViewController animated:YES];
like image 91
Joe Avatar answered Sep 27 '22 19:09

Joe