Nick
Nick

Reputation: 3394

Permanently Hide UISearchDisplayController

I'm trying to hide the searchDisplay controller attached to a UITableView in an iOS 7 Table View Controller. I don't want to temporarily scroll it off the top; I want it to be completely disabled.

In my table view controller code (which, FWIW is set to grouped style because of this), I've got:

self.searchDisplayController.searchBar.hidden = YES;

This does hide the search bar, but unfortunately results in a blank box sitting at the top of my table:

Blank Search Bar Space Screenshot

This blank will scroll off screen just like the search bar. self.searchDisplayController.searchBar.hidden = NO; will bring back the search bar as expected.

I've tried to use suggestions from both the question and answer of this question to shift my table view 44 pixels up, which kind of works except it has the side effect of hiding the pull-to-refresh indicator at the top of my table.

I've also tried setting the frame of my search bar to have no height like so:

self.searchDisplayController.searchBar.frame = CGRectMake(0, 0, self.tableView.frame.size.width, 0);

but this doesn't get rid of the blank space at the top of my table either.

How do I hide a the search bar from a UISearchDisplayController and actually make the space it would occupy collapse as if it wasn't there in the first place?

Upvotes: 0

Views: 115

Answers (1)

Nick
Nick

Reputation: 3394

I eventually dealt with this by chaining the app's behavior circumvent the conditions for this weird behavior. I'm not sure if this behavior was ever fixed in later OS releases.

Upvotes: 0

Related Questions