I recently started to rewrite my iOS app to use the new UISearchController
and a universal storyboard.
My app is available for both devices (iPhone and iPad) so the change to the universal storyboard using the UISplitViewController
was a big advantage.
But sadly the UISearchController
isn't working as expected. I added the UISearchController
with the following lines:
self.searchController = UISearchController(searchResultsController: nil)
self.searchController.searchBar.sizeToFit()
self.searchController.dimsBackgroundDuringPresentation = false
self.myTableView.tableHeaderView = self.searchController.searchBar
self.searchController.searchResultsUpdater = self
self.definesPresentationContext = true
My controller chain is like that:
UISplitViewController
UITabbarController (Master)
UINavigationController
UITableViewController
UINavigationController (Detail)
UINavigationController
UIViewController
The problem is that in the iPad app the UISearchBar
is covered by the UINavigationBar
. But if I switch the tabs and go back to the view. The UISearchBar
is visible. So somehow after a tabbar switch it redraws the view correctly. In the iPhone Version it works automatically correct.
iPad App
After the first launch the UISearchBar
is covered by the UINavigationBar
After switching the tabs the UISearchBar
is displayed correctly
iPhone App
The iPhone app is working correctly without changing the tabs..
What I tried:
- Using different settings of extendingEdges
- Add the SearchController in the viewWillAppear method because I thought I can trick it by adding the search control later on
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…