1

I have tableViewController at the storyboard. I programmatically added searchController to the table header.

private func setupSearchView(){
    if !showSearchBar { return }
    let storyboard = UIStoryboard(name: "Search", bundle: nil)
    resultViewController =
        storyboard.instantiateViewController(withIdentifier: "NewSearchTableViewController") as? SearchResultTableViewController
    searchController = UISearchController(searchResultsController: resultViewController)

    resultViewController?.tableView.delegate = self
    searchController.delegate = self
    searchController.searchResultsUpdater = self
    searchController.searchBar.delegate = self // Monitor when the search button is tapped.

    searchController.hidesNavigationBarDuringPresentation = false
    searchController.dimsBackgroundDuringPresentation = false
    tableView.tableHeaderView = searchController.searchBar
    searchController.searchBar.sizeToFit()
    searchController.searchBar.placeholder = "Search here...".localized
    definesPresentationContext = true

}

When I selected the cell in the table and went to the details screen - it works perfectly. But when I pressed button back, the search bar was scrolled under the navigation bar.

Normal behaiver

Bad behavior after button back pressed

0 Answers0