在 UISearchController 中搜索时无法在 tableView 中滚动

jsb*_*eJS 2 xcode uitableview uikit ios swift

如果我在搜索栏中搜索某些内容(它嵌入在导航栏中),我将无法在 tableview 中滚动。如果我在搜索结束时点击 tableview 并且我可以点击单元格,但我希望能够在搜索时滚动并正常点击单元格。

这就是我添加 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
}
Run Code Online (Sandbox Code Playgroud)

jsb*_*eJS 6

你需要添加这个:

searchController.obscuresBackgroundDuringPresentation = false;
Run Code Online (Sandbox Code Playgroud)