我在表格视图中添加了一个搜索栏。我还有一个导航栏,它应该出现在其下方。在我点击搜索栏之前它工作得很好。当我在屏幕尺寸较大的设备(iPhone 6 以上)上执行此操作时,搜索栏会隐藏在导航栏下方。它在实际的 iPhone 5、5s 上按预期工作。这就是我初始化 searchBar 的方式:
searchController.searchResultsUpdater = self as UISearchResultsUpdating
searchController.dimsBackgroundDuringPresentation = false
definesPresentationContext = true
tableView.tableHeaderView = searchController.searchBar
searchController.hidesNavigationBarDuringPresentation = false
searchController.searchBar.tintColor = UIColor.black
searchController.searchBar.scopeButtonTitles = ["Device", "Person", "OS version"]
searchController.searchBar.delegate = self as UISearchBarDelegate
Run Code Online (Sandbox Code Playgroud)
搜索栏不应该隐藏,因为当我搜索时我也需要导航栏上的分段控件。您知道我该如何解决这个问题吗?