Tab strip that appears after entering the view controller

I am developing an iOS application, and in this application I am using a tab bar controller. And from inside the controller, the tab bar moves to another view controller. Before clicking the view controller, I set the property of this controller

viewController.hidesBottomBarWhenPushed = YES; 

And I'm moving on to another view controller that has a tab bar at the bottom.

The problem is that when I exit the view controller back to the view controller, a tab bar appears in this view. Is there a way to hide the tab bar when a view controller appears?

It will be great if someone can help me.

Thanks in advance.

+6
source share
4 answers

In this case, the viewWillAppear method will be useful. enter this code in your first controller

 -(void)viewWillAppear:(BOOL)animated { self.tabBarController.tabBar.hidden = YES; } 

That way, when the second viewcontroller pops up, it will call this method and your bottom panel will be hidden.

+3
source

Put it when you click the back button

 [self.tabBarController.tabBar setHidden:YES]; [UIView animateWithDuration:0.5 animations:^{ self.tabBarController.tabBar.frame = CGRectMake(self.tabBarController.tabBar.frame.origin.x, self.tabBarController.tabBar.frame.origin.y+self.tabBarController.tabBar.frame.size.height, self.tabBarController.tabBar.frame.size.width, self.tabBarController.tabBar.frame.size.height); } 

I have another answer ...

Put these two methods in all ViewController and control the BOOL variable , which self.hidesBottomBarWhenPushed is YES and NO as per your requirement

 - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.hidesBottomBarWhenPushed = YES; } - (void)viewDidDisappear:(BOOL)animated { self.hidesBottomBarWhenPushed = NO; } 
0
source

Depending on the design of your application, you can set the central object as a delegate to the navigation controller. And hide / show tab bar. this question is hidesBottomBarWhenPushed, but when popped also provides a solution, but I don't like it. By the way, it is not uncommon to show the bottom panel again when a user views a second or deeper level.

0
source

Instead, you can present a second view controller on the tab bar controller. If you want the second view controller to have a navigation bar, you can put it in the new navigation controller.

If this method does not solve your problem, you can create your own tab bar controller so that it can be inside the navigation controller. You can click the second view controller on this navigation controller. To create a custom tab bar controller, you can refer to the Apple Documentation for creating custom container view controllers . I think this works well on iOS 5 and above.

0
source

All Articles