I want to display some UI elements, like a search bar, on top of my app's first VC, and also on top of a second VC that it presents.
My solution for this was to create a ContainerViewController, which calls addChildViewController(firstViewController)
, and view.addSubview(firstViewController.view)
. And then view.addSubview(searchBarView)
, and similar for each of the UI elements.
At some point later, FirstViewController may call present(secondViewController)
, and ideally that slides up onto screen with my search bar and other elements still appearing on top of both view controllers.
Instead, secondViewController
is presented on top of ContainerViewController, thus hiding the search bar.
I also want, when a user taps on the search bar, for ContainerViewController to present SearchVC, on top of everything. For that, it's straightforward - containerVC.present(searchVC)
.
How can I get this hierarchy to work properly?