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 of how this is set up:
let searchResultsController = BLSearchResultsController()
let ret = UISearchController(searchResultsController: searchResultsController)
ret.searchResultsUpdater = self
ret.delegate = self
ret.searchBar.delegate = self;
ret.searchBar.autocapitalizationType = .none
ret.searchBar.placeholder = NSLocalizedString("SearchMsg", comment: "")
ret.searchBar.enablesReturnKeyAutomatically = true
if #available(iOS 13.0, *) {
ret.searchBar.showsScopeBar = false
ret.searchBar.backgroundColor = .white
let searchTextField = ret.searchBar.searchTextField
searchTextField.font = UIFont.tuttiRegularFont(16)
searchTextField.accessibilityIdentifier = "Main Search Field"
if let searchImageView = searchTextField.leftView as? UIImageView {
searchImageView.image = UIImage(named: "home-search-icon")
}
}
The results search controller is a normal UITableViewController
and is just added to the navigationItem.searchController
. There is no fancy presentation code. When building on latest live Xcode and running on the iOS 11/12 device this issue is not present which lead me to believe some underlying iOS 13 change might be causing this glitch.
When debugging the view hierarchy it looks like the result view controller does not reach to the top of the moved search bar.
I've tried fiddling with the modalPresentationModes
trying to exclude the possibility that the changes to the presentation could be the cause, had no luck there.
Has anyone encountered this issue and had luck fixing it?
Just bringing my solution. In my case:
on the UIViewController that contains the UISearchController worked.
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.Finally get through the tough. Just to make the first controller contains the UISearchController to have a translucent navigationBar. Work for me perfectly!
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.
Using
.asyncAfter(deadline: .now() + 0.1)
will cause a glitch in the UI. To get rid of that, get rid of the deadline! UsingDispatchQueue.main.async
is enough.