Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After hiding TabBar can't touch on the area behind the TabBar

I use a TabBarController on my app, in one of the main views (aViewController) i push another controller (bViewController), and hide the TabBar using self.tabBarController.tabBar.hidden=YES;

bViewController have a button at the same place where the tabBar was, and it doesn't catch the touch event.

I have tried placing the button in different places of bViewController, and the area where the tabBar was supposed to be is the only place where touch event is not detected.

I have tried using bViewController outside the tabBarController and it works fine. Any help would be appreciated.

EDIT:

When i press a button on aViewController i call

self.tabBarController.tabBar.hidden=YES;
[self performSegueWithIdentifier:@"aViewToBView" sender:self];

aViewToBview is a push segue declared on storyboard

like image 586
gomezluisj Avatar asked Aug 27 '14 23:08

gomezluisj


1 Answers

For some reason you cannot touch the views underneath the tab bar.

However, if you hide the tab bar and then add a subview to it, the view can then receive user interaction!

This worked for me:

// Create a button that is at the very bottom of the screen
CGFloat buttonHeight = 45.0f;
UIButton *finishButton = [[UIButton alloc] initWithFrame:CGRectMake(
          0, 
          self.view.frame.size.height - self.tabBarController.tabBar.frame.size.height - buttonHeight,
          self.view.frame.size.width,
          buttonHeight)];
//...more initialization of the button...

//Here is our solution:
[self.tabBarController.view addSubview:finishButton];
like image 57
Julio Avatar answered Oct 13 '22 12:10

Julio