[英]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.