在TabBar文件中添加:
IBOutlet UITabBar *myTabBar; //在xib中连接tabBar;
(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController: (UIViewController *)viewController{
if ([viewController isKindOfClass:[ViewInTabBar class]])
{
[self.navigationController setNavigationBarHidden:YES animated:YES];
[self.myTabBar setHidden:YES];
[(ViewInTabBar *)viewController setTab:self];//传递指针
[viewController viewWillAppear:YES];
}
在ViewInTabBar中添加:
TabBar *tab; //接收指针
[tab.navigationController setNavigationBarHidden:NO animated:YES];
[tab.myTabBar setHidden:NO];