Tab Bar Hides when Navigate

混江龙づ霸主 提交于 2019-12-11 11:34:09

问题


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

            }

}

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


回答1:


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

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

UPDATE:

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


来源:https://stackoverflow.com/questions/13581838/tab-bar-hides-when-navigate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!