I'm using the code below in the root view controller to hide the UITableView's header (header has a UISearchbar in it). It works when the app starts up and displays the tableView.. However afterwards, when a row is selected, the detail view is pushed, and the user pops the detail view, the uitableview header is now visible in the root view, which is not what I expected.
Here's the relevant functions:
- (void) viewWillAppear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
self.tableView.contentOffset
= CGPointMake(0, self.tableView.tableHeaderView.frame.size.height);
//it's as if the line above is ignored on when returning from a pushed detail view
}
- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
// theContentOffSet works when I put it hear, but then the user can see it which is not desired
}
The line '[self.navigationController setNavigationBarHidden:YES animated:animated];' is certainly part of the problem, as without it, the code works and the tableView header is scrolled out of view. However the requirement for the root view is for the navigation bar to be hidden, but showing in the detail view.