API
API

Reputation: 51

Empty space below navigation bar with displaysSearchBarInNavigationBar = YES

I've an issue with a search bar in a navigation bar using the property displaysSearchBarInNavigationBar = YES. I have an empty space between the navigation bar and the search content which is equals to the height of the navigation item + status bar. It's just as if during building the view, the framework doesn't know that my search bar is the navigation bar... This empty space appears before tipping anything, and when displaying the result tables.

I haven't found anything related to this issue except this topic: Empty UISearchbar space when combining search bar with Nav bar in iOS7?

I tried with search bar height equals to 0 as said, but it didn't work for me.

Any idea please about this empty space ?

Upvotes: 5

Views: 3117

Answers (5)

Serluca
Serluca

Reputation: 2102

I fixed the empty space using both solution from @Jeremy Hicks and @dsgrant07. Thanks guys.

So put this in the wiewDidLoad:

- (void)viedDidLoad{
   [super viedDidLoad];
   ...
   self.tableView.contentInset = UIEdgeInsetsMake(-44, 0, 0, 0);
}

and configure your storyboard:

enter image description here

Upvotes: 0

Jeremy Hicks
Jeremy Hicks

Reputation: 3740

For me the key was to set the option to enable "Under Opaque Bars" in the StoryBoard editor.

Set "Under Opaque Bars"

Upvotes: 5

I have got the same problem. It happens, when you initialize UISearchDisplayController in viewDidLoad. Replace this part of code to loadView. This should fix this problem!

Upvotes: 1

u10int
u10int

Reputation: 219

I has the same issue and after no solutions others offered actually fixed it for me, I was able to figure out a workaround for this iOS 7 bug: https://stackoverflow.com/a/21493296/580560

Upvotes: 0

dsgrant07
dsgrant07

Reputation: 315

The only solution I have found thus far for this, is to use

self.tableView.contentInset = UIEdgeInsetsMake(-44, 0, 0, 0);

in the viewDidLoad. This sets a negative offset for 44 (known height of searchbar) to clear that extra space.

A bit of a hack but it works.

Upvotes: 2

Related Questions