我想在我的tableViewController中使用新的UISearchController。UISearchController in navigationBar
但是我有點困惑,當我按下searchBar時,它可以在navigationController中向上移動,它與舊的searchDisplayController的關係如何?
目前它只停留在tableHeader中。
這裏是我的代碼:
self.teamSearchController = ({
let controller = UISearchController(searchResultsController: nil)
controller.searchBar.searchBarStyle = UISearchBarStyle.Minimal
controller.dimsBackgroundDuringPresentation = false
controller.searchBar.sizeToFit()
controller.searchBar.showsScopeBar = true
self.tableView.tableHeaderView = controller.searchBar
return controller
})()
控制器:
當我點擊搜索欄:
刪除'controller.hidesNavigationBarDuringPresentation = FALSE'也應該給你你期待 –
我加2圖像這descripe行爲 –
設定searchController的hidesNavigationBarDuringPresentation爲真,並嘗試切換您的ViewController的definesPresentationContext看到結果的行爲。從不隱藏導航欄DuringPresentation爲false,如果您想要提及的行爲,請不要在navigationItem的titleView上放置搜索欄。 – Solomon