Search code examples
iphonethree20

Three20 & TabBarController


I'm stuck on something.

I'm using three20 and the TTTNavigator example. Where I can find a TabBarController that is using :

[self setTabURLs:[NSArray arrayWithObjects:@"tt://crush",
                                               @"tt://crushes",
                                               nil]];

to create each tab.

Ok until here all is ok, my problem is that I have all my tabs without title and image. I know how to set individual when it loads the view controller inside - (void)viewDidLoad :

    self.title = @"crush";
    UIImage* image = [UIImage imageNamed:self.title];
    self.tabBarItem = [[[UITabBarItem alloc] initWithTitle:self.title image:image tag:0] autorelease];

but this is a problem because when you init the app all the tabs except the selected are empty.

Any suggest on how to implement that.


Solution

  • Ok I've resolved, I used the -init method of each view controller.. like usually... but what I need to change was :

    [self setTabURLs:[NSArray arrayWithObjects:@"tt://crush/1",
                                                   @"tt://crushes/2",
                                                   nil]];
    

    And in the map :

    [map from:@"tt://crush/(init)" toViewController:[MakeCrushViewController class]];
    [map from:@"tt://crushes/(init)" toViewController:[MyCrushesViewController class]]; 
    

    for me right now it looks pretty weird.. but ok is working, don't ask me why you need to set 1 and 2 before the links.. if I set 1 on each it crashes...