In viewWillAppear
, I have added UISearchBar
as my headerview of UITableView
. When view loads, I hides UISearchbar
under <
After one hour of tests the only way that works 100% is this one:
-(void)hideSearchBar
{
if([self.tableSearchBar.text length]<=0 && !self.tableSearchBar.isFirstResponder)
{
self.tableView.contentOffset = CGPointMake(0, self.tableSearchBar.bounds.size.height);
self.edgesForExtendedLayout = UIRectEdgeBottom;
}
}
-(void)viewDidLayoutSubviews
{
[self hideSearchBar];
}
with this approach you can always hide the search bar if is empty