0

I want navigate to Rootview of 1st Tabbar item by clicking a button on fourth tabbar using this code just changes the Tabbar selection

code snippets

[self.parentViewController.tabBarController setSelectedIndex:0];

Previous action to be appear in the home view controller .

i need Direct navigation of Home view controller in main page

How to resolve in this issue?

Thanks in advance

Senthil
  • 510
  • 12
  • 28
  • have you a screen before displaying tabbar? Like Login and if successful then display tabbar controller and views OR you have tabbar from the beginning? – Shah Paneri Mar 12 '13 at 09:37

2 Answers2

1

First get your UINavigationController of the first tabbar item.

UINavigationController *navController = [self.tabBarController.viewControllers objectAtIndex:0];

And then navigate to root view controller.

navController popToRootViewControllerAnimated:NO];

That's all. :)

Pei
  • 11,452
  • 5
  • 41
  • 45
0

You have to pop the selected tab bar navigation stack to root.. You can achieve this by several method one is as below..

In your AppDelegate implement the tabbarcontroller delegate function, make sure you have set the tabbarcontroller delegate to AppDelegate..

-(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
 //Check the selected index to 0
 if ([viewController isKindOfClass:[UINavigationController class]] && tabBarController.selectedIndex == 0) { 
    [(UINavigationController *)viewController popToRootViewControllerAnimated:NO]; 
 }
}
iphonic
  • 12,615
  • 7
  • 60
  • 107