我有一個簡單的tableViewController
,一個searchBar
與範圍和navigationBar
。SearchBar和NavigationBar之間的空白 - Swift
當我點擊我的searchBar
我看到我的範圍和所有作品。然後,我點擊一行,我去我的DetailPage
和搜索欄不隱藏(我不知道爲什麼)。
所以我點擊取消然後我回到我的tableView
。當我返回到我的tableView時,我的SearchBar
和我的NavigationBar
之間有一個空格。
這是我的代碼:
self.resultSearchController = ({
let controller = UISearchController(searchResultsController: nil)
controller.searchResultsUpdater = self
controller.hidesNavigationBarDuringPresentation = true
controller.dimsBackgroundDuringPresentation = false
controller.searchBar.sizeToFit()
controller.searchBar.scopeButtonTitles = ["Title", "Author", "Location", "Price", "User"]
self.tableView.tableHeaderView = controller.searchBar
return controller
})()
func updateSearchResults(for searchController: UISearchController)
{
let scopes = resultSearchController.searchBar.scopeButtonTitles
let currentScope = scopes![resultSearchController.searchBar.selectedScopeButtonIndex] as String
filterContentForSearchText(searchText: searchController.searchBar.text!, scope: currentScope)
}
我認爲調整ScrollView Insets爲false適用於您...您的控制器屬性檢查器取消選中調整ScrollView插入 –
我已經嘗試過但結果相同 – Carlo
您是否通過記錄'frames'來確定邊界的實體帳戶? ? (_header,insets,searchbar_)將'viewDidLoad'中的代碼與'viewWill/DidAppear'區分開來的是什麼? – Aerows