Search bar disappears when interactive pop gesture is happening

408 views Asked by At

I'm adding search controller like this:

        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 try to swipe right to pop current viewController (interactive pop gesture activates here) but stay on the same controller the search bar just disappears.

viewController.navigationItem.searchController

holds added search controller but it's not visible.

1

There are 1 answers

0
Ronak Vora On BEST ANSWER

Try to add this code to whatever class viewController is an instance of:

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

That did the trick for me.