views:

29

answers:

1

Hi I have a tab bar application with 4 tab. Each Tab have view added in NavigationController.

So for example, I am on first tab which have table view, user can tap on row and I will navigate into that view. The new view will come with NEW tabs corresponding to that view.

When user click on back button he will again come to home view with original tab bars.

What I did is created a tabbar and added it to window in app delegate. But I am not able to find the way when user tap on row and then I need to replace tab with new new. Should I use this >>

- (void)tabBarController:(UITabBarController *)aTabBarController didSelectViewController:(UIViewController *)viewController {

    if ([viewController isKindOfClass:[UINavigationController class]]) {

        UINavigationController* navController = (UINavigationController*)viewController;
        if ([navController.topViewController isKindOfClass:[SomeViewController class]]) {
                SomeViewController* someViewController = (SomeViewController*)navController.topViewController;
            someViewController.mRecommendedOffers = nil;
..... }

Please any one help to know right approch

+1  A: 

use this code to come to the home view while you move through diff. tabs,no matter in which subview you are

  • (void)tabBarController:(UITabBarController *)tabBarController1 didSelectViewController:(UIViewController *)viewController { NSArray *vc= tabBarController1.viewControllers; for (int i = 0; i < [vc count]; i++) { UINavigationController *nc = [vc objectAtIndex:i]; if (nc == tabBarController1.selectedViewController) { continue; } [nc popToRootViewControllerAnimated:NO]; }

}

Plese vote me up if it helps you.I use the same code for my apps.

sabby