为什么嵌套在tableView中的searchController滚动在navigationBar下?

我在情节提要中有tableViewController。 我以编程方式将searchController添加到表头。

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

}

当我在表格中选择单元格并转到详细信息屏幕时,它可以完美运行。 但是当我向后按下按钮时,搜索栏在导航栏下方滚动。

Normal behaiver

Bad behavior after button back pressed

ningyaoaa 回答:为什么嵌套在tableView中的searchController滚动在navigationBar下?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2704363.html

大家都在问