SOLVED!
So here's the important stuff I was doing wrong. First make sure to alloc and init the array and views when you build your controllers. Here's how I built the array:
Code:
MyView1* vc1 = [[MyView1 alloc] init];
MyView2* vc2 = [[MyView2 alloc] init];
gpTabControllers = [[NSMutableArray alloc] init];
[gpTabControllers addObject:vc1];
[gpTabControllers addObject:vc2];
When you make the change to the new group of tabs, do this:
Code:
NSMutableArray *tc = gpTabControllers;
[tbc setViewControllers:tc animated:YES];
[window addSubview:tbc.view];
If you want to switch back, I would store the first group of controllers into another array. This might keep a lot of stuff in memory though.
Finally, you want to do the TabItems in the controllers themselves, which was where I was getting really confused. Overloading the init function in the MyView classes will do this. Here's a peak at what I added to those classes:
Code:
- (id)init {
if (self = [super initWithNibName:@"MyView1" bundle:nil]) {
self.title = @"Tab Item Title";
UIImage* anImage = [UIImage imageNamed:@"tabItemImg.png"];
UITabBarItem* theItem = [[UITabBarItem alloc] initWithTitle:@"Tab Item Title" image:anImage tag:0];
self.tabBarItem = theItem;
[theItem release];
}
return self;
}
I hope this helps someone else avoid a day long confusion spree like me. Thanks to everyone who was thinking about helping on this one, and thanks to everyone who helps on this site. It is always a big help for me.