給UITarbarController設個delegate,並實現以下方法spa
-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController3d
{it
if ([viewController isKindOfClass:[UINavigationController class]])io
{class
UINavigationController * nav = (UINavigationController*)viewController;select
// 這裏是關鍵,只在棧中存大於一個viewController而且是當前選中的,就不作反應方法
if (nav.viewControllers.count >1 && tabBarController.selectedViewController == viewController)margin
{top
return NO;tab
}
}
return YES;
}