检查:Screenshot
我尝试了所有相关问题的解决方案。但是他们没有一个真正的帮助。
当搜索栏显示结果时,表格视图和搜索栏之间出现了奇怪的间隙。
帮助我找出我的代码出了什么问题:
UITableViewController, UISearchBarDelegate, UISearchResultsUpdating
var searchController = UISearchController()
var resultsController = UITableViewController()
var refreshController = UIRefreshControl()
in override :
configureSearchController()
resultsController.tableView.delegate = self
resultsController.tableView.dataSource = self
refreshController.attributedTitle = NSAttributedString(string: "")
refreshController.addTarget(self, action: #selector(refreshSelector), for: .valueChanged)
tableView.addSubview(refreshController)
searchController.searchBar.delegate = self
automaticallyAdjustsScrollViewInsets = false
definesPresentationContext = true
@objc func refreshSelector()
{
if(!searchLoaded)
{
searchLoaded = true
self.tableView.tableHeaderView = searchController.searchBar
self.navigationItem.rightBarButtonItem = nil
print( "Got ya")
}
refreshController.endRefreshing()
}
func configureSearchController ()
{
searchController = UISearchController(searchResultsController: resultsController)
searchController.searchResultsUpdater = self
searchController.searchBar.layer.borderWidth = 1;
searchController.searchBar.barTintColor = UIColor.searchBarBackgroundGrey()
searchController.searchBar.layer.borderColor = UIColor.searchBarBackgroundGrey().cgColor
self.navigationController?.navigationBar.shadowImage = UIImage()
}
部署目标已设置为9.3