我需要建议,如何在滚动tableView时隐藏/取消隐藏此搜索栏?
这是我的代码:
private let searchController = UISearchController(searchResultsController: nil)
并设置方法:
private func setupSearchController() {
searchController.searchResultsUpdater = self
if #available(iOS 9.1, *) {
searchController.obscuresBackgroundDuringPresentation = false
} else {
// Fallback on earlier versions
}
searchController.searchBar.placeholder = " "
if #available(iOS 11.0, *) {
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = false
searchController.obscuresBackgroundDuringPresentation = false
} else {
// Fallback on earlier versions
}
definesPresentationContext = true
self.automaticallyAdjustsScrollViewInsets = false
}
我猜想,其他方法也很重要。那么,安装程序中缺少什么呢?
最佳答案
你有没有尝试过
navigationItem.hidesSearchBarWhenScrolling = true
关于ios - 通过Swift滚动隐藏/取消隐藏UISearchBar,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52355761/