0

I am trying to achieve the following but dont know the best way to go about it so any tips would be great.

My app has a first root view which has a tab bar with 4 tabs, one of the tabs contains a table view. When an item is selected on the table view I want to display a details page (which I can do fine) but also completely change the tab bar to match the new set of data.

A good example of this is the free F1 2011 app. When selecting "Live Timing" you are taken to a new screen with a different tab bar (with a home button at the top to get back to previous screen.)

How would be the best way to go about implementing this?

Thanks in advance.

Fraser

Fraser
  • 11
  • 4

2 Answers2

0

Try linking the the view controller with the table to the new UITabBarController and make it a modal segue. In the class for your viewcontroller with the table do an

#import "FirstViewControllerInNewTabBar"

Then in the

(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

method you will want to do the following:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    // Since your segue is pointing to the new tab bar controller
    UITabBarController *tabBarController = (UITabBarController *)segue.destinationViewController;  

    // Now you want to pass data into the new tab bar's view controllers
    FirstViewControllerInNewTabBar *vc = (FirstViewControllerInNewTabBar *)[tabBar.viewControllers objectAtIndex:0];

    // Assuming FirstViewControllerInNewTabBar has a property 'NSString *dataToPassIn'
    vc.dataToPassIn = @"Potato";
}
CoderNinja
  • 571
  • 3
  • 7
  • 20
0

Just create a new tabbarcontroller view (as you would do in the app delegate) in the didSelectRowAtIndexpath: method.

thvanarkel
  • 1,601
  • 1
  • 12
  • 19
  • Thanks for the info. I have still been having problems with this as the views are switching but my tab bar is not shown or is party covered. But I think that is down to the issue that you cant push a tab bar controller to a navigation controller. I came across the following links which seem to explain this: [link](http://stackoverflow.com/questions/1251981/tab-bar-will-no-work-as-a-subview-of-another-view-but-works-fine-as-a-subview-of) – Fraser Apr 17 '11 at 10:50