Search bar disappears when interactive pop gesture is happening
Asked Answered
L

1

7

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.

Lingle answered 27/12, 2017 at 15:10 Comment(2)
Same issue. Did you find a fix ?Smedley
No. Will update in case some news.Lingle
B
1

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.

Bifacial answered 4/6, 2019 at 22:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.