0

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?

Community
  • 1
  • 1
Nick
  • 3,172
  • 3
  • 37
  • 49
  • have you thought of checking if the search display is actually hidden? Something such as if(self.searchDisplayController.searchBar.hidden) { // make the frame = 0; } else { // make frame = 44} and then set the frame below that – user2277872 Feb 17 '14 at 23:10
  • I set the hidden property in a if-statement based on a standardUserDefaults value. I did try setting the frame for the searchBar in the same if-statement while setting the hidden property; I still had the side effect of the missing pull-to-refresh indicator. – Nick Feb 17 '14 at 23:47

1 Answers1

0

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.

Nick
  • 3,172
  • 3
  • 37
  • 49