0

I'm having trouble using the space left behind by my hiding a UITabBar.

I have a UITabBarController with a UINavigationController, whose root view controller just has a UIWebView. I'm using auto-layout constraints to make the webview fill the view which works fine (and fills the available space) when I hide the navigation/status bars.

However, when I hide the tab bar (using setNavigationBarHidden), the tab bar is hidden but the space it vacates isn't used up by the webview, as expected.

Searching similar questions suggest using hidesBottomBarWhenPushed before pushing the view. I don't want to have to push another VC (or have to reload the webview) when rotating the device. Others suggest to resize the frame (like https://stackoverflow.com/a/1554637/1429412 ), but I have not been able to do that successfully.

What is the best way to hide the tab bar in one orientation, but not the other, and have a view fill the space vacated by the tab bar?

Portrait screenshot, showing UIWebview with a green background behind status/nav bar and tab bar as expected: https://i.stack.imgur.com/Hzj9k.png

Landscape screenshot showing hidden status/navbar and tab bar. The webview contents have extended to the top (navbar), but not so to the bottom (tab bar). However, the webview itself (the only element with a green background) has extended down just not its contents (regardless of length): https://i.stack.imgur.com/sdk75.png

If I examine the views at runtime (using FLEX), and click the viewable content area, it shows UIWeBrowserView view with shorter 271 height. Clicking the area where the tabbar space is shows _UIWebViewScrollView with the full 320 height. In code, I can see the UIWebView's .contentSize is only 568x271. I tried various combinations of setting the frame on the webview and its subviews, without success.

Right now, without any frame resizing hacks, the code is simply:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    [[self navigationController] setNavigationBarHidden:UIInterfaceOrientationIsLandscape(toInterfaceOrientation) animated:YES];
    [[UIApplication sharedApplication] setStatusBarHidden:UIInterfaceOrientationIsLandscape(toInterfaceOrientation) withAnimation:UIStatusBarAnimationSlide];
    self.tabBarController.tabBar.hidden = UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

I'm using xCode 6.1 for an iOS7+ project.

What should I do next? Thanks in advance for any pointers!

Community
  • 1
  • 1
cgarvey
  • 11
  • 2

1 Answers1

0

That is simply the way Tabbars are suppose to work, The only form of UIView that allows tab bors to be covered are modal views presentviewcontroller .... dismissviewcontroller Apple has a lot of samples just search for it.

Paulo
  • 1,245
  • 10
  • 8
  • I don't disagree but it's UX that's often used. Like the tap to reveal / hide when viewing a photo in the stock photos app. Are they really creating a second view with an other UIImageView for the photo and presenting/dismissing that on tap? (Thanks for your feedback!) – cgarvey Dec 13 '14 at 15:07
  • I'm pretty sure the photo app employs a modal view and a UITapresponder when you tap the screen. .... check out the change in background color. For iPad apps they have this pop view in lieu of modals that completely cover the screen - but I am sure you know that. – Paulo Dec 14 '14 at 00:09