I add a search controller as follows:
viewController.navigationItem.searchController = searchController viewController.navigationItem.hidesSearchBarWhenScrolling = false viewController.definesPresentationContext = true searchController.dimsBackgroundDuringPresentation = false searchBarContainer.translatesAutoresizingMaskIntoConstraints = false searchBarContainer.heightAnchor.constraint(equalToConstant: 0).isActive = true
and when you try to scroll right to pop current viewController (an interactive pop gesture is activated), but remaining on the same controller, the search bar just disappears.
viewController.navigationItem.searchController
contains the added search controller, but it does not appear.
source share