I had one nav bar controller, which I embedded in a tabbar controller. I then put two more nav bar controllers onto the story board and created push segues from the tab bar controller to the two new navbar controllers, so I expected the log statement below to be 3, for the number of view controllers on the tab bar controller, however, it logged 1. The last line of code below also obviously threw an out of bounds error because there is no objectAtIndex:1
. Can you explain? Why aren't the second and third navbar controllers that I created push segues to in storyboard present in the viewControllers property of the tab bar controller?
UITabBarController *tbc = (UITabBarController *)self.window.rootViewController;
NSLog(@"tbc %lu", (unsigned long)[[tbc viewControllers] count]);
UINavigationController *nav = (UINavigationController *)[[tbc viewControllers] objectAtIndex:0];
UINavigationController *nav2 = (UINavigationController *)[[tbc viewControllers] objectAtIndex:1];
UITabBarController
at your app it must be a root view controller. Ok, I see the problem now, why don't you useviewControllers
property of theUITabBarController
? – A-Live1
for the first nav bar controller that I put on the story board (which I embedded in the tab bar controller). – BrainLikeADullPencil