In our project we specified that
hidesNavigationBarDuringPresentation = false
on a particular UIViewController
's UISearchController
. The searchController has an array of scope titles. This so far works fine up to iOS 10, but in iOS 11 betas, it looks like the false setting of hidesNavigationBarDuringPresentation is ignored and messes up our display. To make sure it's not because of other factors in my project, I created a bare-bone test project with just a single UITableViewController
, with a UISearchController
initialized with another simple UITableViewController
. The following code is in the viewDidLoad()
method on the main view controller:
self.title = "Search Bar Scope Test"
let searchViewController = SearchViewController(style: .plain)
searchController = UISearchController(searchResultsController: searchViewController)
searchController!.searchBar.sizeToFit()
tableView.tableHeaderView = searchController!.searchBar
searchController?.hidesNavigationBarDuringPresentation = false
searchController?.searchBar.scopeButtonTitles = ["scope 1", "scope 2", "scope 3", "scope 4", "scope 5"]
When the last line assigning scopeButtonTitles
is not present, the navigation bar didn't get hidden and the search bar remains in its original position. However, with that line present, the NavigationBar
becomes hidden and the searchBar
plus the scope buttons all moved up in portrait mode on both iPhone and iPad, but stays the same in landscape mode (even if the scope buttons are many and can't fit in one line).
Did anybody else encounter this? Is this a bug or expected behavior (certainly not our desired behavior though) in iOS 11, and is there any workaround?
Thanks!