-1

我在视图控制器 1 中添加了这个标签栏,它运行良好,唯一的问题是我希望它执行以下功能[self.navigationController popViewControllerAnimated:YES];,但在视图控制器 2 中,当标签栏按钮被触摸时。最好的行动方案是什么?

UINavigationController *homeNavigationController = [[UINavigationController alloc] initWithRootViewController:homeViewController];
homeNavigationController.tabBarItem = [[DSTabBarItem alloc] initWithFinishedSelectedImage:[UIImage imageNamed:@"home"] 
                                                            finishedUnselectedImage:[UIImage imageNamed:@"home1"]
                                                                                 iconSize:CGSizeMake(76, 59)
                                                                                tag:0];
[tabBarViewControllers addObject:homeNavigationController];
4

2 回答 2

0
DetailSettingsViewController *settings = [[DetailSettingsViewController alloc] initWithNibName:@"DetailSettingsViewController" bundle:nil];

[self.navigationController pushViewController:settings animated:YES];
于 2013-03-19T09:11:44.340 回答
0

如果您以编程方式添加了 tabbarcontroller 。并在该类中添加以下方法。然后您的导航控制器将更改为根视图。你可以将你自己的放在 if 到你的要求之间。

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    if ([self.tabBarController.selectedViewController isKindOfClass:[UINavigationController class]])
    {
        [(UINavigationController*)self.tabBarController.selectedViewController popToRootViewControllerAnimated:YES];


    }

}
于 2013-03-19T03:52:06.440 回答