UISearchBar’s delegate method searchBarCancelButtonClicked is not called on search cancel when search bar is integrated into the navigation bar on iOS 27

Hi, I would like to share an issue with UISearchBar's delegate method searchBarCancelButtonClicked on iOS 27 beta.

On iOS 27 beta, when search bar is integrated into navigation bar’s items, tapping search cancel button doesn’t invoke UISearchBar’s delegate method searchBarCancelButtonClicked:.

Steps to reproduce:

  1. Create UINavigationController with one UIViewController
  2. Set up searchController. Set searchController.searchBar.delegate, preferredSearchBarPlacement = .integratedButton, searchBarPlacementAllowsToolbarIntegration = false
  3. Tap the search button and type a query
  4. Tap the search cancel button

Expected: On iOS 26, the searchBarCancelButtonClicked delegate method is called.

Actual: On iOS 27 beta, the searchBarCancelButtonClicked delegate method is NOT called.

On iOS 27 beta, if search bar is “stacked” or placed in the toolbar rather than the navigation bar, the bug does not reproduce.

I’m using Xcode Version 27.0 beta 6 with latest available iOS 27 iPhone 17 Pro simulator (24A5423a).

I reported the issue via Feedback Assistant with a minimal reproduction example and 2 videos comparing the behavior between iOS 26 and iOS 27 beta. Here is the report ID: FB24636315.

Here is the minimal reproduction example:

// SceneDelegate.swift
import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

  var window: UIWindow?

  func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    guard let windowScene = scene as? UIWindowScene else { return }
    let window = UIWindow(windowScene: windowScene)
    window.rootViewController = UINavigationController(rootViewController: ViewController())
    window.makeKeyAndVisible()
    self.window = window
  }
}

// ViewController.swift
import UIKit

final class ViewController: UITableViewController {

  private let allItems = (1...30).map { "Item \($0)" }
  private var items: [String] = []
  private var cancelCount = 0

  override func viewDidLoad() {
    super.viewDidLoad()
    items = allItems
    updateTitle()

    let searchController = UISearchController(searchResultsController: nil)
    searchController.searchBar.delegate = self

    navigationItem.searchController = searchController
    navigationItem.preferredSearchBarPlacement = .integratedButton
    navigationItem.searchBarPlacementAllowsToolbarIntegration = false

    tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
  }

  private func updateTitle() {
    title = "Cancel presses: \(cancelCount)"
  }

  override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    items.count
  }

  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
    cell.contentConfiguration = {
      var config = cell.defaultContentConfiguration()
      config.text = items[indexPath.row]
      return config
    }()
    return cell
  }
}

extension ViewController: UISearchBarDelegate {

  func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
    print("searchBarCancelButtonClicked(_:)")
    cancelCount += 1
    updateTitle()
    items = allItems
    tableView.reloadData()
  }
}

Thank you in advance!

Thank you for reporting.

I confirmed your report has been seen by the relevant engineering team.

At this moment, they have not provided a workaround. It might be the case the resolution requires updates to the frameworks you are using, updates will likely be provided through Feedback Assistant. There, you can track if the report is still being investigated, has a potential identified fix, or has been resolved in another way.

For more details on Feedback Status, please see “Understanding the Status of Your Feedback” linked here: https://developer.apple.com/bug-reporting/status

Test new versions as they are released and use this thread to update us if the issue has been resolved or still occurs.

Feel free to add these details in your report so the relevant engineering team is aware of a timeline of the issue associated well. I will minter this thread and pass along important details to the team also.

Thank you.

 Travis

UISearchBar’s delegate method searchBarCancelButtonClicked is not called on search cancel when search bar is integrated into the navigation bar on iOS 27
 
 
Q