Search code examples
iosswiftxcodeuitableviewuikit

Can't scroll in tableView while searching in UISearchController


if i am searching something in the searchbar (it is embedded in the navigationBar) I can't scroll in the tableview. If i tap on the tableview while searching the search ends and i can tap the cells, but i want to be able to scroll while searching and tap cells normally.

This is how i add the searchController:

override func viewDidLoad() {
    super.viewDidLoad()
    navigationController?.navigationBar.prefersLargeTitles = true

    tableView.delegate = self
    tableView.dataSource = self

    let searchController = UISearchController(searchResultsController: nil)
    searchController.searchBar.delegate = self
    navigationItem.searchController = searchController
}

Solution

  • You need to add this:

    searchController.obscuresBackgroundDuringPresentation = false;