0

I've developed a ViewController that shows different data according to the input parameter. I would like to use a tabBar interface and call the same ViewController from different tabs by passing them to different parameters. Can I do this? I get errors if I specify the ViewController's NIB in tabBar item.

Can you help me please?
Thanks in advance.

iknow
  • 8,358
  • 12
  • 41
  • 68
Cris
  • 12,124
  • 27
  • 92
  • 159
  • Found the solution here: http://www.iphonelife.co.uk/creating-a-uitabbarcontroller-programmatically/ – Cris Oct 07 '10 at 16:05

1 Answers1

2

Create two different instances of your ViewController:

MyViewController *vc1 = [[MyViewController alloc] initWithNib:@"MyViewController" bundle:nil];
MyViewController *vc2 = [[MyViewController alloc] initWithNib:@"MyViewController" bundle:nil];

UITabBarController *tabs = [[UITabBarController alloc] init];
[tabs setViewControllers:[NSArray arrayWithObjects:vc1, vc2, nil] animated:NO];
Josh Hinman
  • 6,745
  • 7
  • 38
  • 47