[英]Blank space between SearchBar and NavigationBar - Swift
我有一個簡單的tableViewController
,一個帶作用域的searchBar
和一個navigationBar
。
當我單擊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)
}
嘗試添加
self.automaticallyAdjustsScrollViewInsets = false;
self.extendedLayoutIncludesOpaqueBars = true
在viewDidload
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.