6
votes

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

1
do you present bViewController modally or push it?cph2117
Can you post your code?cph2117
I met the same problem, have you solved it?morisunshine
couldn't solve it, i just placed the button above the tabBar area, looks ugly, but have to live with that.gomezluisj

1 Answers

2
votes

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];