4

I have a UISearchBar in a tableviewcontroller like so:

self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0,    self.view.frame.size.width, 44)];
self.tableView.tableHeaderView = self.searchBar;

When the user taps in the search bar to search, the searchbar expands to show the cancel button, but then also moves down about 20 pixels, so in effect there is a 20 pixel blank space above the searchbar between the search bar and the navigation bar. I don't understand the moving down behavior and what I can do to prevent it. Does anyone know what exactly might cause that to happen and how I can prevent it?

kevin
  • 1,552
  • 2
  • 12
  • 26

1 Answers1

0

I was having the same issue, although with a UISearchBar being presented by UISearchController. For me, removing the line

self.edgesForExtendedLayout = UIRectEdgeNone;

from the presenting VC's viewDidLoad method stopped the search bar dropping down.

Community
  • 1
  • 1
Zoë Smith
  • 1,004
  • 1
  • 11
  • 18