简体   繁体   中英

How to hide the tab bar on click of a tab in an iPhone app

I am doing a multi view app, in that I have 4 tabs, and I have view controllers in each tab. In one tab I have grouped table view controller, on click of that tab it will go to that grouped table view. Every thing is going fine.

But last row of the table is hidden under tab bar, so I need to hide the tab bar when I enter into that screen. How can I do this?

I am using this in Appdelegate to create tabs programmatically.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    
    UINavigationController *localNavigationController;
    tabBarController = [[UITabBarController alloc] init];
    NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:5];
    
     //add first tab View Controller
    RootViewController *ViewController;
    ViewController = [[RootViewController alloc] initWithTabBar];
    
    localNavigationController = [[UINavigationController alloc] initWithRootViewController:ViewController];
    [localControllersArray addObject:localNavigationController];
    [localNavigationController release];
    [ViewController release];
    
     //add second tab View Controller
    StudentDataEntry *GroupViewController;
     GroupViewController = [[StudentDataEntry alloc] initWithTabBar];
    localNavigationController = [[UINavigationController alloc]
                                 initWithRootViewController:GroupViewController];
    [localControllersArray addObject:localNavigationController];
    [localNavigationController release];
    [GroupViewController release];
}

Try this:

BOOL hiddenTabBar = NO;

- (void) hidetabbar {




 NSArray *array = self.tabBarController.view.subviews;
NSLog(@"array SubView %@",array);
[UIView animateWithDuration:1.0 delay:0.0f options:UIViewAnimationCurveLinear animations:^(){
    for(UIView *view in self.tabBarController.view.subviews)
    {
        
        if([view isKindOfClass:[UITabBar class]])
        {
            
            if (hiddenTabBar) {
                [view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
            } else {
                [view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
            }
        } else {
            if (hiddenTabBar) {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
            } else {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
            }
            
        }
    }
} completion:^(BOOL isfinsihed){
     hiddenTabBar = !hiddenTabBar;
   
}];




}

if your last row is not visible in your view then there is no need to hide tab bar for that you have to make your table view height according to that, a tab bar is 48 px so minus this 48 px height from your table view height and also if there is a navigation bar at the top then also minus 44 more px from height then it will be visible. And also you can set content inset for table view to make it visible.

Try this

yourviewcontroller.hidesBottomBarWhenPushed=YES;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM