1

I'm doing it in all tab controllers:

(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    self.tabBarController.tabBar.hidden = NO;
}

-

(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    self.tabBarController.tabBar.hidden = YES;
}

And it's working when I'm going forward controller by controller, but on back way my TabBar disappearing.

  • well, when you go back, it also runs the `viewWillAppear` for the viewController you will go back to, so it runs the `hidden = NO`. Your rootViewController(s) must not set it hidden on `viewWillAppear`. – Erakk May 21 '15 at 21:13
  • when I go back from controller2 to controller1, at first called controller1's viewWillAppear then controller2's viewWillDisappear. But I can figure our the right way to do what I need. – Gegham Harutyunyan May 21 '15 at 21:18
  • what if you used `viewDidAppear´ or `viewDidDisappear´ depending on witch you want to appear last – rob180 May 21 '15 at 21:57
  • I have tried and it works, but the TabBar blinking. – Gegham Harutyunyan May 21 '15 at 22:00

2 Answers2

0

The UITabBar is disappearing when going back, because the viewWillDisappear: method gets called, which executes the self.tabBarController.tabBar.hidden = YES; line. However, I'm not 100% clear on what you're trying to accomplish, so I'm not sure how to provide a solution other than removing the offending line of code.

socaljoker
  • 304
  • 2
  • 11
  • I have UITabBarController with 2 controllers: Controller1 and Controller2. In both controller I have add these:(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.tabBarController.tabBar.hidden = NO; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; self.tabBarController.tabBar.hidden = YES; } and when I'm going from controller2 to controller1, my tabBar gets disappeared, cause of it is that at first called controller1's viewWillAppear then controller2's viewWillDisappear. – Gegham Harutyunyan May 21 '15 at 21:22
  • I want to see tabbar only on UITabBarController.viewControllers, on all other screens it should not be shown – Gegham Harutyunyan May 21 '15 at 21:30
  • If you have your View Controller structure set up properly, when the UITabBarController is removed from the screen, it will automatically remove the UITabBar since the UITabBar's view is contained in the UITabBarController's view. So it's possible that your view structure is improperly arranged. – socaljoker May 21 '15 at 21:39
0

something like this should do the trick. edit: since it did not work try this solution and you said that you only want to show on UITabBarController

-(void)viewWillAppear:(BOOL)animated
{
  [super viewWillAppear:animated];

  if([self isKindOfClass:[UITabBarController class]])
  {
    self.tabBarController.tabBar.hidden = NO;
  }else{
    self.tabBarController.tabBar.hidden = YES;
  }
}
rob180
  • 901
  • 1
  • 9
  • 29