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

有帮助吗?

解决方案

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

其他提示

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]; 
 }
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top