1
votes

I'd like to have the UISearchBar be initially hidden behind the navigation bar using the UITableView's contentInset and contentOffset, however, I can't seem to get UITableViewController, UISearchDisplayController and automaticallyAdjustsScrollViewInsets to play nice.

If I set the contentInset, the controller will reset it when displayed.

Setting automaticallyAdjustsScrollViewInsets to NO hides the table under the UINavigationBar and won't respond to me setting the UIViewController's view property (in order to change the frame). If I override loadView and set the view directly, it removes the UITableView and just setting the frame doesn't have any effect.

Is this possible in iOS 7?

1

1 Answers

1
votes

Not sure if this is what you were looking to do (and I know ages have passed) but this will start your search bar hidden if the search bar is embedded in the TableView header.

- (void) hideSearchBar
{
    CGPoint contentOffset = self.tableView.contentOffset;
    contentOffset.y += CGRectGetHeight(self.tableView.tableHeaderView.frame);       //  hide the Search Bar until dragged down
    self.tableView.contentOffset = contentOffset;
}