导航时隐藏标签栏 [英] Tab Bar Hides when Navigate

查看:66
本文介绍了导航时隐藏标签栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,我的项目中有四个选项卡首先选择一个选项卡,即家庭班级当用户通过选择任何选项卡导航到任何其他班级时,我必须检查是否有时间如果用户已登录我的应用程序,那么他将导航至他选择的班级,然后转到登录屏幕".

I have Four Tabs in My Project By Default First tab is selected which is Home Class When user navigate to any other class by selecting any tab i have to check that time that if user is loggedin in my application then he will navigate to class which he selected else he move to Login Screen.

 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类,因此请检查此

IF i navigate to Login Screen my tab bar gets Hidden and when i debug the code i came to know that Create Poll class is also get called in background i check this link to show tab bar which is hidden but cant get success. Please help me guys i m stucked with this problem from last 3 days. Cant see my tabbar in Login Screen.Please Help

推荐答案

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

just write this code in viewWillAppear: method to hide and show the UITabBar

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

更新:

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

post these method in AppDelegate.m file and when you want to show and hide the Tabbar at that time create AppDelegate object and call this method

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

这篇关于导航时隐藏标签栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆