I have an Iphone application in which i have 3 tabitems with a tabbarcontroller.Inside the tabbarcontroller each viewcontroller is a navigation controller.when selecting the second tab i have a view controller.when selecting a button on that i am pushing another view controller to the self.navigation 控制器。在那个视图控制器中,我正在推动并像那样前进。但问题是当我再次选择 tabitem 时,pushviewcotroller 显示在那里。但是当我选择选项卡时,我再次需要那个 rootview,我试过了在我的代码中像这样但没有用,`
-(void)tabBarController:(UITabBarController *)tabbBarController didSelectViewController:(UIViewController *)viewController
{
if(tabBarController.selectedIndex==0)
{
//[viewController.tabBarItem setImage:[UIImage imageNamed:@"pinboard_hvr.png"]];
}
else if (tabBarController.selectedIndex==1)
{
NSLog(@"%@",viewController);
//[viewController.tabBarItem setImage:[UIImage imageNamed:@"pinboard_hvr.png"]];
// NSArray *array = [viewController.navigationController viewControllers];
NSLog(@"%@",array);
// [self.navigationController popToViewController:[array objectAtIndex:0] animated:YES];
[viewController.navigationController popToRootViewControllerAnimated:YES];
//[appdelegate.navigationController popToRootViewControllerAnimated:YES];
}
else if (tabBarController.selectedIndex==2)
{
//[viewController.tabBarItem setImage:[UIImage imageNamed:@"pinboard_hvr.png"]];
}
}
`我已经尝试过弹出到根目录以及获取视图控制器数组,但没有成功。有人可以帮我实现这一目标吗?