简体   繁体   中英

Hide and Add UITabbarController

I'm new in ios Development. I have some question.

Now, in my project i have UITabBarController1 with 2 viewControllers(ViewController1, ViewController2).

ViewController1 is start Page. When I run Every Page(ViewController1, ViewController2, ViewController3, ...) have UITabBarController.

But in some page(Example : ViewController4) i want to hide and add New UITabBarController2 in ViewController4

  • if I use command "hideButtomBar" in ViewController4 : UITabBarController is not appear.
  • if I don't use command "hideButtomBar" in ViewController4 : UITabBarController1 and UITabBarController2 is appear(both)

how to fixed it

thank for help and sorry for my mistake about english. ^^

Try using this to hide tabbar

 - (void)hideTabBar:(UITabBarController *) tabbarcontroller
 {
       CGRect screenRect = [[UIScreen mainScreen] bounds];

       [UIView beginAnimations:nil context:NULL];
       [UIView setAnimationDuration:0.5];
       float fHeight = screenRect.size.height;
       if(  UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) ){
           fHeight = screenRect.size.width;
       }

       for(UIView *view in tabbarcontroller.view.subviews){
            if([view isKindOfClass:[UITabBar class]]){
                 [view setFrame:CGRectMake(view.frame.origin.x, fHeight, view.frame.size.width, view.frame.size.height)];
            }else{
                 [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
                 view.backgroundColor = [UIColor blackColor];
            }
       }
       [UIView commitAnimations];
 }

and

 [self hideTabBar: UITabBarController1];
app.tabBarController.tabBar.hidden=TRUE;

app.tabBarController.tabBar.hidden=TRUE;

//Set some tab
[app.tabBarController setSelectedIndex:0];

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