Search code examples
iosiphoneuitableviewios7uitabbarcontroller

In iOS 7, why UITableView's contentInset has bottom value despite the UITabBarController is hidden?


I don't know why UITableView has bottom inset automatically despite I make UITabBarController be hidden by calling [setHidden:YES] before.

The view controller who has UITableView is a child of UITabBarController. I already know that automaticallyAdjustsScrollViewInsets helps any UIScrollView get proper 'contentInset' depending on status of it's container view controller.

So, I expected that UITableView's bottom contentInset will be 0 if UITabBar is hidden. But, doesn't do that.

Although automaticallyAdjustsScrollViewInsets is YES, should I manually adjust that value when UITabBar is hidden?


Solution

  • Tab bars have never been meant to be hidden - after all why have a UITabBarController if you want to hide the tab bar. In the documentation, you are warned not to modify the tab bar object directly:

    You should never attempt to manipulate the UITabBar object itself stored in this property.

    This is exactly what you are doing when setting it to hidden.

    In iOS6 this has worked, but now in iOS7, it doesn't. And it seems very error prone to hide it. When you finally manage to hide it, if the app goes to the background and returns, Apple's layout logic overrides your changes. There are many such triggers.

    My suggestion is to change your design. Perhaps display the data modally.