I found a work around for this issue. I'm annoyed I didn't think of this months ago.
Instead of setting up the scope bar titles at the start, wait until the search controller is about to be activated the first time.
In the code in my original post, remove these lines from setupSearch:
let searchBar = search.searchBar
searchBar.scopeButtonTitles = [ "One", "Two", "Three" ]
and add the line:
search.delegate = self
Then add the following extension to the view controller class:
extension ViewController: UISearchControllerDelegate {
func willPresentSearchController(_ searchController: UISearchController) {
if searchController.searchBar.scopeButtonTitles == nil {
searchController.searchBar.scopeButtonTitles = [ "One", "Two", "Three" ]
}
}
}
This change works under iOS/iPadOS 26.0 and later. Now the scope buttons do not interfere with whatever content is immediately below the search bar.
Topic:
UI Frameworks
SubTopic:
UIKit
Tags: