Is it possible to hide the tabbar when a button is pressed to allow a full screen view of the content?

后端 未结 6 1656
情书的邮戳
情书的邮戳 2020-11-29 22:21

I have a UITabBar in the detail view of my navigation based application. I am storing text and images in a tableview and would like the user to be able to tap on a cell to

6条回答
  •  無奈伤痛
    2020-11-29 22:59

    The best workaround I have found is to change the view size so that it covers the tabbar. Here's my code for hiding the statusBar, navBar, and tabBar when a row is selected:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    
    if (appDelegate.navigationController.navigationBar.hidden == NO)
    {
        [[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
        [appDelegate.navigationController setNavigationBarHidden:YES animated:YES];
    
        [UIView beginAnimations:@"HideTabbar" context:nil];
        [UIView setAnimationDuration:.2];
        self.view.frame = CGRectMake(0,0,320,480);
        [UIView commitAnimations];
    }
    if (appDelegate.navigationController.navigationBar.hidden == YES)
    {
        [[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
        [appDelegate.navigationController setNavigationBarHidden:NO animated:YES];
    
        [UIView beginAnimations:@"ShowTabbar" context:nil];
        [UIView setAnimationDuration:.2];
        self.view.frame = CGRectMake(0,0,320,368);
        [UIView commitAnimations];
    }   
    }
    

提交回复
热议问题