When running the App on iOS 13 beta 6, using Xcode 11 beta 5 I\'m encountering the strange gap when presenting search results view controller:
Here\'s a bit o
We had the same issue and the solution was to set Under Opaque Bars (since we use opaque bars)
We already had Top and Bottom checked, adding the third moved the search results controller to the correct location.
Finally get through the tough. Just to make the first controller contains the UISearchController to have a translucent navigationBar. Work for me perfectly!
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.isTranslucent = true
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.isTranslucent = false
}
For me the problem was that UISearchController didn't update it's frame when search bar moved upwards. I fixed it by setting frame of UISearchController to the frame of it's presenting view controller.
extension UISearchController {
open override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if let presentingVC = self.presentingViewController {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.view.frame = presentingVC.view.frame
}
}
}
}
In viewWillAppear animation of search bar did not start so you have to wait for a split second. When animation starts, frame of presenting VC is set to the correct value and then you can update frame of your UISearchController. The solution is a hack but it works fine for me.
extendedLayoutIncludesOpaqueBars = true
did help to some extent.
Along with this, I had to update
navigationController?.navigationBar.prefersLargeTitles = false
when we start searching and set it back to true
when search bar is dismissed.
Setting
extendedLayoutIncludesOpaqueBars = true
in the UIViewController
used to show the search results, fixed the issue for me.
The easiest solution is to set this on your searchResultsController:
searchResultsController.edgesForExtendedLayout = UIRectEdgeNone;