0

I have a tabBarController (that i created using code without Interface Builder):

self.tabBarController = [[[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:firstController,      secondController, thirdController, nil];

when i'm in the second tab (secondController) and i press a button:

UIButton *button1;

I want to pass to another view (seconddController for example):

- (void)actio:(UIButton *)button1
{
seconddController *scdd = [[seconddController alloc] init ];
[self presentModalViewController:scdd animated:YES];
}

But the problem is that i want to stay on the second tab and not that the view occupies all the space, so how to add that seconddCntroller to the second tab in lieu of secondController?

Thank you

zak
  • 39
  • 1
  • 4

1 Answers1

1

If I understand you correctly, you need to have secondController managed by a navigation controller so that the structure is:

self.tabBarController.viewControllers = [NSArray arrayWithObjects:firstController,      secondNav, thirdController, nil];

Then you can use pushViewController:animated: to show scdd over secondController.

Phillip Mills
  • 30,888
  • 4
  • 42
  • 57
  • i want to put another view into the same tab, i can do it by having a subview of the one which is displayed, but i want a new controller for the new view.but i don't understand what you said, sorry, can you be more explicit ?? – zak Aug 06 '12 at 16:17
  • Do you understand how a navigation controller works? (If not, take a look at the class description for `UINavigationController`. If you do, what's not clear in what I wrote?) – Phillip Mills Aug 06 '12 at 16:24
  • Right on, suggest @zak read the "View Controller Programming Guide" published by Apple – CSmith Aug 06 '12 at 17:02