1

I hide my tab bar like so:

self.tabBarController.tabBar.hidden = YES;

And because now there is a black bar where it once stood I stretch the view which is a UIWebView on top(or is it under?) that empty space. The UIWebView is in a UIViewController. I do that with a constraint which by default is like so:

enter image description here

The code for the constraint:

if(self.tabBarController.tabBar.hidden){
    self.webviewBottomConstrain.constant = -self.tabBarController.tabBar.frame.size.height;
}else{
    self.webviewBottomConstrain.constant = 0;
}

However if I tap the device on the place where the TabBar was it will not execute. It is as if there is something invisible there with the size of the tab bar. I have also tried hiding it the way this thread sugests. Still the same result.

Update: It seems that when you tap on the invisible tab bar the tap is recognized by the tab bar and not by the view that is visible under the tab bar

h3dkandi
  • 1,106
  • 1
  • 12
  • 27

5 Answers5

4

self.extendedLayoutIncludesOpaqueBars = YES; this will solve you problem

manmangood
  • 56
  • 2
  • Won't this apply different display logic to when the tab bar is shown as well. Should I possibly set it to NO when I show the tab bar and to YES when I hide the tab bar? – h3dkandi Aug 08 '16 at 13:34
  • This is literally the only solution that has worked for me – Adam Jun 12 '17 at 21:59
0

You hide your tabBar by setting its hidden property to NO? Try setting it to YES. Unless I am misunderstanding what you are trying to do, it seems like your tab bar is not hidden with that code.

Another thing I would check is to see if User Interaction Enabled is checked for the web view. If it is not, that can seem like there is something invisible blocking you from interacting with your view.

Lucas
  • 66
  • 4
  • But it is hidden. When I inspect it with the "debug view hierarchy" it is not shown there. The interaction is enabled, I can click any where else on the web view. – h3dkandi Jun 24 '16 at 06:54
0

Well I am using quite ugly hack to fix this. I am hiding the tab bar in another way now:

if (shouldShow) {
    self.hidesBottomBarWhenPushed = NO;
    UIViewController *someView = [[UIViewController alloc] init];
    [self.navigationController pushViewController:someView animated:NO];
    [self.navigationController popToViewController:self animated:NO];

} else if (shouldHide) {
    self.hidesBottomBarWhenPushed = YES;
    self.tabBarController.hidesBottomBarWhenPushed = YES;
    self.navigationController.hidesBottomBarWhenPushed = YES;
    UIViewController *someView = [[UIViewController alloc] init];
    [self.navigationController pushViewController:someView animated:NO];
    [self.navigationController popToViewController:self animated:NO];
}

I do need that random view because I cannot push the view on itself.

h3dkandi
  • 1,106
  • 1
  • 12
  • 27
0

I had the same issue when hiding the tab bar by moving it offscreen to the bottom. My custom UITabBarViewController was intercepting the touch events in the area vacated by the tab bar, so instead of changing the frame of the tab bar to move the tab bar offscreen, I extended the height of my tab bar view controller so that the tab bar still moved offscreen, but the child view above the tab bar now filled that space. This allowed the touches to be received by the child view.

archsten
  • 481
  • 3
  • 4
0

As you may see with view hierarchy instrument, UITabBar is not directly blocking your tap, but your current view controller's view height is not full screen:

Views arrangement with tabbar

So, the tap doesn't response because your finger's y position is higher than view's maxY.

Code like this (inside your UITabBarController) will expand your view's height, according to tabbar visibility, and all tap events will work correctly.

func updateTabBarAppearanceWithDegree(_ degree: CGFloat) {
    let screenHeight = UIScreen.main.bounds.size.height
    let tabBarHeight = self.tabBar.frame.size.height

    self.tabBar.frame.origin.y = screenHeight - tabBarHeight * degree
    self.tabBar.alpha = degree

    let currentNavigation = self.selectedViewController as? UINavigationController
    if let currentTopView = currentNavigation?.viewControllers.last?.view {
        currentTopView.frame.size.height = self.tabBar.frame.origin.y
    }
}
Mikhail Vasilev
  • 720
  • 6
  • 13