The search bar disappears when an interactive pop gesture occurs

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.

+6
source share
1 answer

Try adding this code to any viewController class that is an instance:

 override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) self.definesPresentationContext = true } 

It helps me.

0
source

Source: https://habr.com/ru/post/1274350/


All Articles