<分区>
我想做一个这样的搜索栏。
当我向下滚动时,联系人应用程序中的搜索栏保持不变。我想用 It doesn't scroll down along with table view 这个属性制作一个搜索栏。我在 TableView Controller 中做了我的应用程序。这是我在 TableView Controller 中的代码。
myTableViewController(在我的 viewDidLoad 函数中):
searchController = UISearchController(searchResultsController: nil)
searchController.hidesNavigationBarDuringPresentation = false
searchController.searchBar.searchBarStyle = UISearchBarStyle.Prominent
searchController.searchBar.sizeToFit()
tableView.tableHeaderView = searchController.searchBar
definesPresentationContext = true
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
由于这段代码,它应该像联系中的搜索栏一样工作
tableView.tableHeaderView = searchController.searchBar
我做错了什么吗?如果不是,那么如何使我的搜索栏不随 TableView (在 TableView Controller 中)向下滚动?