On iOS 26, UISearchController becomes non-interactive when presenting a second UISearchController from another tab of a UITabBarController.
let tabBar = UITabBarController()
let first = FirstViewController()
first.title = "First"
let second = SecondViewController()
second.title = "Second"
let nav1 = UINavigationController(rootViewController: first)
let nav2 = UINavigationController(rootViewController: second)
nav1.tabBarItem = UITabBarItem(
title: "First",
image: nil,
tag: 0
)
nav2.tabBarItem = UITabBarItem(
title: "Second",
image: nil,
tag: 1
)
tabBar.viewControllers = [
nav1,
nav2
]
The app has two tabs. Each tab has its own UINavigationController.
Tab 1:
A UISearchController is assigned to navigationItem.searchController.
class FirstViewController: UIViewController {
private let searchController = UISearchController(
searchResultsController: nil
)
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .systemBackground
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchResultsUpdater = self
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = false
definesPresentationContext = true
}
}
Tab 2:
A button presents another UISearchController using present(_:animated:).
class SecondViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .systemBackground
let button = UIButton(
type: .system
)
button.setTitle(
"Open Search",
for: .normal
)
button.addTarget(
self,
action: #selector(openSearch),
for: .touchUpInside
)
button.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(button)
NSLayoutConstraint.activate([
button.centerXAnchor.constraint(
equalTo: view.centerXAnchor
),
button.centerYAnchor.constraint(
equalTo: view.centerYAnchor
)
])
definesPresentationContext = true
}
@objc private func openSearch() {
let searchController = UISearchController(
searchResultsController: nil
)
navigationController?.present(
searchController,
animated: true
)
}
}
On iOS 17 and iOS 18 this works correctly.
On iOS 26:
The search controller appears.
The Cancel button works.
The search text field cannot receive touches and does not become first responder.
If I remove:
navigationItem.searchController = searchController
from Tab 1, the search controller in Tab 2 works correctly.
This looks like a UIKit regression introduced in iOS 26.
1
0
82