I have a UINavigationController
which contains two UIViewControllers
, set up in a storyboard:
Each of these controllers has a UISearchBar
included in their navigation item by the following line in viewDidLoad()
:
navigationItem.searchController = UISearchController(searchResultsController: nil)
When the second view controller is pushed onto the navigation stack while the search bar is visible in the first view, the animation does not render correctly: the navigation height does not transition to the correct height smoothly - it transitions to the size of the next navigation item if it had its search bar visible, and then snaps to the correct size when the animation is complete. This results in part of the view being obscured during the animation.
See the attached recording, showing both the "normal" animation (when the search bar is hidden) and then the incorrect animation:
I've also created put together a very simple reproduction of this issue, with just 7 lines of code in its view controller, which demonstrates the issue.
Is there a way I can prevent this happening?