我在视图控制器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];
答案 0 :(得分:0)
如果您以编程方式添加了tabbarcontroller。在该类中添加以下方法。 然后导航控制器将更改为根视图。你可以把它自己放在if和你的要求之间。
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if ([self.tabBarController.selectedViewController isKindOfClass:[UINavigationController class]])
{
[(UINavigationController*)self.tabBarController.selectedViewController popToRootViewControllerAnimated:YES];
}
}
答案 1 :(得分:0)
DetailSettingsViewController *settings = [[DetailSettingsViewController alloc] initWithNibName:@"DetailSettingsViewController" bundle:nil];
[self.navigationController pushViewController:settings animated:YES];