- UISearchController searchaBar遮挡c
- UISearchController进入编辑状态后,距离状态栏太
- UISearchController取消按钮被遮挡的处理
- iOS11 UISearchController的使用
- Swift5.2 - UISearchController的简单
- UISearchController和UISearchBar的C
- iOS - Swift UISearchController
- 开始用Swift开发iOS 10 - 18 Search Bar
- UISearchController的简单实用
- ios 对UISearchController的封装使所有的回
在同一页面跳转时的情况
即searchController = UISearchController.init(searchResultsController: nil)
//创建searchController时
searchController = UISearchController.init(searchResultsController: nil)
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "搜索"
searchController.searchBar.delegate = self
searchController.delegate = self
searchController.searchBar.sizeToFit()
myTableView.tableHeaderView = searchController.searchBar
self.definesPresentationContext = true;

出现如上情况,是因为searchBar的frame改变导致,tableView的hearder
也需要跟随变化
func didPresentSearchController(_ searchController: UISearchController) {
self.myTableView.frame = CGRect.init(x: 0, y: 20, width: ScreenWidth(), height: ScreenHeight()-20)
myTableView.tableHeaderView?.bounds = searchController.searchBar.frame
}
func didDismissSearchController(_ searchController: UISearchController) {
self.myTableView.frame = CGRect.init(x: 0, y: 0, width: ScreenWidth(), height: ScreenHeight()-64)
myTableView.tableHeaderView?.bounds = searchController.searchBar.frame
}
即可解决

网友评论