1

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?

Deepesh
  • 8,065
  • 3
  • 28
  • 45
Kyokook Hwang
  • 2,682
  • 21
  • 36

2 Answers2

0

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.

Léo Natan
  • 56,823
  • 9
  • 150
  • 195
  • That's right! I ended up finding nice solution with your advice. I found out 'hidesBottomBarWhenPushed' property on UITabBarController. I think that it is a indirect way to hide the tabbar properly. – Kyokook Hwang Dec 23 '13 at 06:52
  • Be careful, it is known to also cause trouble. – Léo Natan Dec 23 '13 at 06:52
  • Thanks a lot. I have just noticed that it's difficult to control visible status of the tabbar with multiple pushing and popping. Anyway, thank you again for your advice. – Kyokook Hwang Dec 23 '13 at 07:52
0

Putting this here for anyone who gets this problem for nested view controllers.

My view controller containment hierarchy is:

UINavigationController
  |--UIViewController
     |--UITabBarController
        |--UIViewController

The last view controller has a UITableView whose scrollIndicatorInsets keep getting offset by the tab bar controller's UITabBar height even if it is hidden.

Solution: Set automaticallyAdjustsScrollViewInsets to false in the view controller that contains the tab bar controller (and is inside the UINavigationController). No need to set additional properties in the tab bar controller itself and the second view controller where the UITableView is.

Matthew Quiros
  • 13,385
  • 12
  • 87
  • 132