[英]Blank space between SearchBar and NavigationBar - Swift
I have a simple tableViewController
, a searchBar
with scopes and a navigationBar
. 我有一个简单的
tableViewController
,一个带作用域的searchBar
和一个navigationBar
。
When I click on my searchBar
I see my scopes and all works. 当我单击
searchBar
我会看到我的范围和所有作品。 Then I click on a row and I go to my DetailPage
and the search bar isn't hidden (I don't know why). 然后我单击一行,然后转到我的
DetailPage
,搜索栏没有隐藏(我不知道为什么)。
So I click cancel and then I return to my tableView
. 因此,我单击取消 ,然后返回到
tableView
。 When I return to my tableView there is a blank space between my SearchBar
and my NavigationBar
. 当我返回tableView时,我的
SearchBar
和NavigationBar
之间有一个空格。
This is my code: 这是我的代码:
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)
}
try to Add 尝试添加
self.automaticallyAdjustsScrollViewInsets = false;
self.extendedLayoutIncludesOpaqueBars = true
in viewDidload
. 在
viewDidload
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.