2012-11-27 215 views
1

我的项目中有四个标签默认情况下第一个标签页被选为Home Class当用户通过选择任何标签来导航到任何其他类时,我必须检查用户是否在我的应用程序中登录那么他将导航到他选择的课程,否则他将转到登录屏幕。导航栏中的标签栏隐藏

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]; 

      } 

}

如果我定位到登录界面我的标签栏被隐藏,当我调试的代码,我才知道,创建民意调查类也被调用在后台我检查这个link显示选项卡酒吧是隐藏的,但不能取得成功。请帮助我,我从最近3天就遇到了这个问题。 不能看到我的TabBar在登录Screen.Please帮助

+0

你想要什么?你想在登录屏幕上显示tabbar? –

+0

@ParasJoshi YES – iSanjay

+0

然后看到下面我的代码我编辑它与否为隐藏属性 –

回答

1

只写这些代码viewWillAppear:的方法来隐藏和显示UITabBar

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

UPDATE:

AppDelegate.m文件发布这些方法和当您想要显示并隐藏Tabbar时创建AppDelegate对象并调用此方法

- (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]; 
} 
+0

我已经把这个之前,但它不工作 – iSanjay

+0

我认为你设置LoginViewController作为AppDelegate RootViewController,然后如果用户登录sussess然后你添加tabbar从代表我认为你这样做只是检查这一点,并发布AppDelegate队友didFinishLaunchingWithOptions方法.. –

+0

我已经设置我的主视图控制器在根视图控制器现在如果用户选择任何选项卡当时我必须chk用户是登录或不,然后移动到登录屏幕或移动到选定的屏幕 – iSanjay