Question

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

Était-ce utile?

La solution

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. :)

Autres conseils

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]; 
 }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top