views:

93

answers:

1

Every time a user changes a tab, for the selected tab I want to push it to its top level controller. I have implemented the delegate method for the Tabbarcontroller like this:

- (void) tabBarControler:(UITabBarController *)tabBarController didSelectViewController:(UIViewController*)viewController{
    [[self navigationController] popToRootViewController Animated:NO];  
}  

This does nto seem to work but I can confirm the method is being called every time I change tabs

A: 

Based on your code, it looks like a simple misspelling. The correct method is [[self navigationController] popToRootViewControllerAnimated:NO] (you had an extra space). Also, tabBarController is misspelled, which would prevent the method from being called.

If that doesn't work, it's possible that [self navigationController] might be wrong (depending on where you're calling the method from). If you're calling from your AppDelegate, it should probably be something like [tabBarController.selectedViewController.navigationController popToRootViewControllerAnimated:NO]. Hope that helps.

eman
Well I did insert a NSLog(@"Hello") statement to check if the method was being called...I'll try the last piece of code you mentioned. Thanks!
Jimmy