1

I have a tabbed application and each tab has a navigation controller with table views in it.

In one of the view from a tab, I want to present the first view controller of another tab.

My tabViewController.viewControllers has an array of navigation controllers for each tab.

I cant seem to present the view controller directly without accessing the navigation controller and I guess you cant present a navigation controller. What am I doing wrong??

SunnyPenguin
  • 137
  • 4
  • 15

1 Answers1

1

If I understood you correctly, you can access to your root controller something like that: [[tabViewController.viewControllers objectAtIndex:index] objectAtIndex:0], but I dont think you can display one view twice. So you still should recreate this view controller to display it in another tab as childViewController, for example

Ossir
  • 3,109
  • 1
  • 34
  • 52
  • `UINavigationController *mycont= [self.tabBarController.viewControllers objectAtIndex:2]; [self.tabBarController presentViewController:[mycont.viewControllers objectAtIndex:0] animated:YES completion:nil];` The above code throws error Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller .' – SunnyPenguin Apr 22 '13 at 08:45
  • Do I recreate the viewController and the navigation controller and then replace it in the `tabbarController.viewControllers` again? Am I correct in interpreting your answer? – SunnyPenguin Apr 22 '13 at 08:51
  • I should have been clearer. I found what I was looking for, I should have just set the `self.tabBarController.selectedIndex=index;` Thanks anyway. – SunnyPenguin Apr 22 '13 at 09:12