I'd like to present a navigation controller from a tab bar controller's tab's root view controller and have the tabs from the tab bar controller visible.
Here's a photo of an example storyboard:
The tab bar controller has a relationship to the ItemOneViewController
, which is implemented like this:
import UIKit
class ItemOneViewController: UIViewController {
private func presentNavigationController() {
let id = "NavController"
guard let vc = storyboard?.instantiateViewController(withIdentifier: id) else { return }
present(vc, animated: true)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
presentNavigationController()
}
}
I hoped that by presenting the navigation controller from the root view controller of a tab on a tab bar controller that the navigation controller would be presented behind the tabs, but when I run the described app, this is what the simulator looks like:
This is what the view hierarchy looks like:
I think I remember a previous colleague mentioning that a UINavigationController
will replace the view stack, which makes sense but is there anyway to keep it or bring the UITabBarController
with it?
I've tried adjusting the presentation style and context but haven't had any luck.