iOS 9 searchBar disappears from table header view when UISearchController is active iOS 9 searchBar disappears from table header view when UISearchController is active ios ios

iOS 9 searchBar disappears from table header view when UISearchController is active


I'm not sure what exactly is the problem but I 'fixed' it by:

self.searchController.hidesNavigationBarDuringPresentation = NO;self.definesPresentationContext = NO;

My guess is that UISearchController is doing something funky when it is trying to present as a navigation bar. So, this is a hack but it at least doesn't block the user. The search bar doesn't do the cool animation and cover up the navigation bar.


It seems all of us got the same problem but they were solved in different ways. However none of the suggested answers worked for me :(. Nevertheless thank you all for your time.

I got a solution that solved my problem. It is setting Extend Edges - Under Opaque Bars of my (MyModalView: UITableViewController) to true in the Storyboard using Interface Builder.

In summary:

MyModalView: UITableViewController, in Storyboard using Interface Builder has

Extend Edges:- Under Top Bars ticked- Under Bottom Bars ticked- Under Opaque Bars ticked

screenshot


I found it's the simulated metrics (top bar) in storyboard that's cause this problem.In my case, the following lines work, but I still don't know why.

- (void)willPresentSearchController:(UISearchController *)searchController {    // do something before the search controller is presented    self.navigationController.navigationBar.translucent = YES;}-(void)willDismissSearchController:(UISearchController *)searchController{    self.navigationController.navigationBar.translucent = NO;}