views:

117

answers:

1

I have a Tab Bar Controller created in Interface Builder

Within the Tab Bar are 4 Navigation Controllers.

Each controller functions separately and perfectly (yay!)

What I need to be able to do is a push a view controller onto a different nav controllers stack and switch the focus onto the appropriate tab bar item (so that the user moves sideways (to a different tab) and up (to a new view) at the same time).

This is my first time working with a tab bar controller, and while it's been simple to this point, figuring this out is giving me fits. Any tips you can toss my way would be much appreciated.

A: 

I would use something like the following as a starting point, where whichTab is the index of the tab you will be pushing onto, and newViewController is the view controller you want to push and switch to. You may need to play around with the ordering of pushing versus switching.

UITabBarController *tabBarController = (UITabBarController *)[[[UIApplication sharedApplication] delegate] tabBarController];

UINavigationController *otherNavController = (UINavigationController *)[[tabBarController viewControllers] objectAtIndex:whichTab];

[otherNavController pushViewController:newViewController animated:NO];
tabBarController.selectedIndex = whichTab;
Frank Schmitt
I was attempting to make it far more complicated than it was. Thanks for the quick, simple, and flawless answer!
Derek