My app has tab bar controller that loads 3 view controllers in its viewDidLoad method.
- (void)viewDidLoad
{
[super viewDidLoad];
...
[self setViewControllers:@[firstViewController,
secondViewController,
thirdViewController,
]];
}
I want it to show up with a view controller (homeViewController) that is different from these three controllers. When the tab bar is first loaded none of these three tab bars will be selected. I want to change them by pressing tab bar items and return to home view by pressing navigation left bar button.
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:btnImage
style:UIBarButtonItemStylePlain
target:self
action:@selector(setHomeView)];
How can I show the homeViewController when the tab bar controller is first loaded without added it to tab bar items?
UITabBarController
is not meant to be used this way. EachUITabBarController
essentially will have it's ownUINavigationController
in most cases and hence, their own stack. These tabs are all separated from one another. If I go tofirstViewController
, then get pushed to another VC, then click on the second tab, I no longer have the navigation left bar button to get back to the home VC. You're not meant to be able to be on a Home VC, then go to Tab 1, then tab 3, and still have a back button to get back to the home VC. Rethink your UI/UX flow. – LyricalPandaUITabBarController
to get around this issue so they can do self.window.rootViewController = {homeVC,firstVC,secondVC,thirdVC}. Otherwise if it's just a landing screen they don't care about being able to go back to it once they are past it. – LyricalPanda