I am programmatically coding an app with a tab bar and a navigation controller, I've deleted the storyboard, the app also runs fine and shows the navigation bar when the 'secondViewController' is not part of the mainNavigationController.viewControllers array, however when I add the secondViewController, the navigation bar doesn't show up on the view. What could I be doing wrong that isn't showing the navigation bar? Should I be making the mainNavigationController the rootViewController instead?
let mainNavigationController = MainNavigationController()
let mainTabBarController = MainTabBarController()
let mainViewController = MainViewController()
let secondViewController = SecondViewController()
mainNavigationController.title = "Single Meal"
secondViewController.title = "Group Meal"
mainViewController.title = "Single Meal"
mainNavigationController.viewControllers = [mainViewController, secondViewController]
mainTabBarController.viewControllers = [mainNavigationController, secondViewController]
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = mainTabBarController
mainViewController
and you can push-to and pop-fromsecondViewController
... and tab 2 shows justsecondViewController
which would, of course, not show a nav bar. Is that not what you're getting? – DonMagUINavigationController
and push/pop between two view controllers. Why not start there and then add yourUITabBarController
? That way you can - at least - narrow down the specific issue you are facing. (It would also clarify things to us too.) – dfd