1

I have a TabBarController & 4 tabs with their individual ViewControllers (embedded in NavigationController/TableViewController) created using interface. Dynamically added multiple BarButtons on The ViewController1. The current view Controller of Tab 1 has to be replaced on click of a BarButton. How should I go about it?

opensource
  • 23
  • 5

1 Answers1

2

This is the snippet you should play around with, to get the hang of it more

self.tabBarController.selectedIndex = 1;

I have answered this question before too, you can refer to that answer as well here

[self.tabbarController setViewControllers:arrayOfNewViewControllers];
self.tabbarController.selectedIndex = 0;
Community
  • 1
  • 1
Saheb Roy
  • 5,899
  • 3
  • 23
  • 35
  • 1
    Thanks. But i don't want to set first tab but replace the ViewController of first tab with some other ViewController. Say initially first tab's ViewController is ABC on clicking the BarButton it should change to some other ViewController XYZ (being in the same tab). – opensource Mar 17 '15 at 07:25
  • Thanks. Found out later. When I try to display a static table view (designed in storyboard) using the above code the view gets replaced but the table appears blank. If I use the code below content gets displayed. Is it the right way to do it? `UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; UIViewController *tableView = [storyboard instantiateViewControllerWithIdentifier:@"MyTableView"];` – opensource Mar 17 '15 at 12:44