6

I implemented a search function for an UITableViewController like this:

    self.resultSearchController = ({
        let controller = UISearchController(searchResultsController: nil)
        controller.searchResultsUpdater = self
        controller.dimsBackgroundDuringPresentation = false
        controller.searchBar.sizeToFit()

        self.tableView.tableHeaderView = controller.searchBar
        return controller
    })()

The problem I've been experiencing is that if I click on it, my navigation bar and my navigationcontrollers header disappear. Is there a solution to stop this behaviour (in swift)?

Not clicked:

Not clicked

Clicked:

Clicked

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
0x52
  • 883
  • 1
  • 11
  • 17

1 Answers1

13

The UISearchController has a property called hidesNavigationBarDuringPresentation, maybe that can help you.

EDIT: Just tried it myself and it works, just add this line:

searchController.hidesNavigationBarDuringPresentation = false
Fernando Mata
  • 482
  • 1
  • 10
  • 22