tableHeaderView preserves state when popping viewController except ContainerViewController - ios

I have a tableViewController with a tableHeaderView. When I'm at the top of the tableView and I scroll the tableView up slightly the tableHeaderView is hidden and can reappear again by scrolling down slightly. This is the default behaviour.
When I push to a viewController then pop back to the tableViewController, the state of the tableHeaderView is preserved. i.e., if it was hidden it remains hidden and if it was visible it remains visible.
However, for some reason when I push to another viewController that has a containerView and then pop back, the tableHeaderView always displays. Even if it was hidden before pushing.

The Issue was that I had checked Hide Bottom Bar On Push in storyboard on the viewController that I was pushing to. For some reason this caused the tableHeaderView to always display when popping back. Unchecking this fixed the problem. Instead the tabBar can be hidden in viewDidLoad of the pushed viewController with the following:
self.tabBarController?.tabBar.isHidden = true
Hope this will help somebody.

Related

TableView Scrolls Over NavBar

When I scroll my TableView, it scrolls over my navigation bar (which I made without using the built in navigation bar for various reasons). See below:
Unscrolled:
Scrolled up:
How do I make it so that the TableView scrolls under the Navbar?
SOLVED:
I checked the "clips subviews" box for the table view to fix this problem.
To me, it looks like there may be an issue with your view hierarchy. Now, I assume that you built your own navigation bar by subclassing UINavigationBar.
In order to get the kind of behavior you need, you should have the following:
UIWindow's rootViewController is an instance of UINavigationController.
UINavigationController.navigationBar = your subclass of UINavigationBar.
UINavigationController.viewControllers[0] = UITableViewController
The UITableViewController.view = your UITableView

scrollViewWillBeginDragging in UITableView does not work

UIScrollView|
UITableView
I have 5 UITableView in UIScrollView.
My program has a Navigation Controller inside TabbarController.
When I run the program, everything is OK. It can drag up and down to refresh data in tableview. It can drag left and right to change tableview.
But when I push the button on the Navigation Bar, it will push a view.
Then I push the back button on the navigation bar on this view.
The scrollViewWillBeginDragging in UITableView not worked. I can just receive the scrollViewWillBeginDragging in UIScrollView.
More worse, it can drag all directions.
Why?
already fix this bug , set self.automaticallyAdjustsScrollViewInsets = NO;

TabBar hopelessly covering my ContainerView

I have a custom UIContainerView. Inside the UIContainerView is a Controller with a UITableView. The TabBar keeps covering the last cell of my TableView. How do I prevent that from happening? I already tried the suggestions at TableView Showing Behind Tab Bar and Tab Bar covers TableView cells in iOS7 and Tab bar covers UITableView's last cell at all levels: in the VC holding my container view and in the VC of the TableView, as appropriate. I am not having much success. I set the constraints, I remove constraints — still nothing. Help!
I am using iOS7 and Xcode5.

UITableView last cell hidden by UITabBarController

I am facing a strange issue.
I have a UITableView in the initial UIViewController of the UITabBarController. At first everything is alright, but when I change the tab and come back to first tab the last cell of UITableView is hidden by the tabbar.
How can I fix this?
select your specific ViewController from storyboard then un-check Under Bottom Bar property.

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?
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.
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.

Resources