Denis
Denis

Reputation: 795

Prevent UISearchController from hiding view Navigation Bar in IOS8

I have a UIViewController embedded in a popover. This controller has two subviews, a UINavigationBar and a UITableView. I try to implement the new search API (as SearchDisplayControlled is deprecated in iOS8).

When I click in the search bar (displaying two scopes), everything is all right, and the navigation bar is still visible. But when I start typing in the search bar, the navigation bar disappears, replaced by a blank area. I tried to add self.searchController.hidesNavigationBarDuringPresentation = NO; in the updateSearchResultsForSearchController: method, but got no result. (note that the controller viewDidLoad defines self.definesPresentationContext = YES;)

Any idea to force navigation being displayed anytime?

Upvotes: 3

Views: 911

Answers (2)

Clement Joseph
Clement Joseph

Reputation: 1293

This work for me

self.navigationController.navigationBar.translucent = true;

Upvotes: 1

Zoë Smith
Zoë Smith

Reputation: 1084

I was seeing the same effect - in my case setting the property in viewDidLoad in my view controller made the navigation bar stick around:

- (void)viewDidLoad {
    ...
    self.definesPresentationContext = YES;
    ...
}

When I'd previously set the same property from a class that was managing the search (initialized after -viewDidLoad had already been called on the VC), I saw the same behaviour of a blank nav bar that you describe.

Upvotes: 1

Related Questions