左侧在iPhone 7模拟器中显示我的应用程序。右侧是设备中显示的应用程序。在搜索栏中点按时,导航栏会向上滑动,然后向下滑回,如图像中显示“这是什么?”所示。文字。
我的搜索控制器的代码如下,并且在viewDidLoad中被调用。
//MARK: - Search Controller
func configureSearchController() {
searchController.dimsBackgroundDuringPresentation = false
definesPresentationContext = true
// to receive updates
searchController.searchResultsUpdater = self
// Set up searchbar of search controller
searchController.searchBar.scopeButtonTitles = ["All", "Something", "Something"]
searchController.searchBar.delegate = self
// add the searchbar to the tableview
tableView.tableHeaderView = searchController.searchBar
// hack to fix ocassional bugs
searchController.searchBar.sizeToFit()
}