参考this link我在UITabDelegate
添加了UITabBarControllerDelegate
和AppDelegate.h
并添加了
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if ([viewController isKindOfClass:[UINavigationController class]])
{
[(UINavigationController *)viewController popToRootViewControllerAnimated:NO];
}
}
AppDelegate.m
中的。问题仍未解决。我在我的项目中使用XIB并处理登录和注销以相应地启用和禁用标签栏。
答案 0 :(得分:2)
你应该这样写:
if ([viewController isKindOfClass:[ClassName_Of_Selected_ViewController class]])
{
//[(UINavigationController *)viewController popToRootViewControllerAnimated:NO];
[viewController.navigationController popToRootViewControllerAnimated:NO];
}