0

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?

nhgrif
  • 61,578
  • 25
  • 134
  • 173
Eddy
  • 3,533
  • 13
  • 59
  • 89
  • 1
    You need to push your new view onto the stack rather than making it the root view. Your root view needs to be the tab bar controller. – nhgrif Dec 03 '13 at 13:11
  • @nhgrif how do you do that? – Eddy Dec 03 '13 at 13:19
  • 1
    This may help you. http://stackoverflow.com/questions/17676718/how-can-i-programmatically-set-selected-tab-of-uitabbarcontroller-while-also-tri – Boran Dec 03 '13 at 13:19

0 Answers0