I have a tabbed application for which I set a UITabBarController
in the AppDelegate
. It has a few tabs and I can move easily from one to another.
Now I need to go from one of the ViewControllers to another programatically. This is what I do:
ImageScreenViewController *imageViewController = [[ImageScreenViewController alloc] init];
UIImageView *iv = [[UIImageView alloc] initWithImage:imageToShow];
imageViewController.imageView = iv;
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
appDelegate.window.rootViewController = imageViewController;
This takes me to the imageViewController, where my image is displayed correctly. But the tab bar is gone.
I tried setting it like this:
imageViewController.tabBarController = appDelegate.tabBarController;
but it turns out that tabBarController is "readOnly" on UIViewController. I tried the workarounds, trying to set the variable directly, but no luck.
So how do I get my tab bar to continue showing, even when I'm in my new view controller?