1

默认情况下,我的项目中有四个选项卡第一个选项卡被选中,这是家庭课程当用户通过选择任何选项卡导航到任何其他课程时,我必须检查那个时间,如果用户登录我的应用程序,那么他将导航到他的课程选择其他他移动到登录屏幕。

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

            }

}

如果我导航到登录屏幕,我的标签栏被隐藏,当我调试代码时,我知道 Create Poll 类也在后台被调用,我检查此链接以显示隐藏但无法成功的标签栏。请帮助我,从过去 3 天开始,我一直在解决这个问题。在登录屏幕中看不到我的标签栏。请帮助

4

1 回答 1

1

只需在方法中编写此代码viewWillAppear:即可隐藏和显示UITabBar

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

更新:

将这些方法发布到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];
}
于 2012-11-27T10:15:09.390 回答