选项卡栏在导航时隐藏

我有四个选项卡在我的项目默认第一个选项卡被选中,这是家庭类当用户导航到任何其他类通过select任何选项卡我必须检查时,如果用户login我的应用程序,然后他将导航到他的类否则select他移动到login屏幕。

if(appDelegate.sessionId==0) { Login *objLogin=[[[Login alloc] initWithNibName:@"Login" bundle:nil] autorelease]; [self.navigationController pushViewController:objLogin animated:YES]; } else { CreatePoll *objLogin=[[[CreatePoll alloc] initWithNibName:@"CreatePoll" bundle:nil] autorelease]; [self.navigationController pushViewController:objLogin animated:YES]; } 

}

如果我导航到login屏幕我的标签栏获取隐藏,当我debugging代码我来知道创build投票类也被调用在后台我检查这个链接显示标签栏是隐藏的,但不能获得成功。 请帮助我的家伙从这个问题最近3天stucked。 无法看到我的标签栏在login屏幕。请帮助

只需在viewWillAppear:方法中隐藏并显示UITabBar

 AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; [appDelegate.tabBarController.tabBar setHidden:NO]; 

更新:

AppDelegate.m文件中发布这些方法,当你想显示和隐藏Tabbar的时候创buildAppDelegate对象并调用这个方法

 - (void) hideTabBar:(UITabBarController *) tabbarcontroller { int height = 480; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.3]; for(UIView *view in tabbarcontroller.view.subviews) { if([view isKindOfClass:[UITabBar class]]) { [view setFrame:CGRectMake(view.frame.origin.x, height, view.frame.size.width, view.frame.size.height)]; } else { [view setFrame:CGRectMake(view.frame.origin.x,view.frame.origin.y, 320, 436)]; } } [UIView commitAnimations]; } - (void) showTabBar:(UITabBarController *) tabbarcontroller { int height = 480; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.3]; for(UIView *view in tabbarcontroller.view.subviews) { if([view isKindOfClass:[UITabBar class]]) { [view setFrame:CGRectMake(view.frame.origin.x, height, view.frame.size.width, view.frame.size.height)]; } else { [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, height)]; } } [UIView commitAnimations]; }