views:

218

answers:

1

A buddy of mine asked for a quick sample of code for an app skeleton that would use a TableView to call a TabView. I estimated an hour.

After more hours than I want to admit messing around in IB, I gave up and implemented the following code.

Can anyone tell me how to do this in IB? I was careful (I thought) to make all the right connections, but no go. I even had another (working) app where I went through and step-by-step made the same connections. I got errors about "Changing the delegate of a tab bar managed by a tab bar controller is not allowed..." (This when I connected the TabBar's delegate to the File's owner, even though another app was working fine with that setting)

Until I wrote this code, I never got the tabbar view, only the view that came with the view xib... (I tested by putting a label on the view).

Thanks in advance...

UITabBarController *tabBarController = [[[UITabBarController alloc] initWithNibName:nil bundle:nil] autorelease];
    NumberOneViewController *numberOneViewController = [[[NumberOneViewController alloc] initWithNibName:@"NumberOneViewController" bundle:nil] autorelease];
    NumberTwoViewController *numberTwoViewController = [[[NumberTwoViewController alloc] initWithNibName:@"NumberTwoViewController" bundle:nil] autorelease];
    NumberThreeViewController *numberThreeViewController = [[[NumberThreeViewController alloc] initWithNibName:@"NumberThreeViewController" bundle:nil] autorelease];
    NumberFourViewController *numberFourViewController = [[[NumberFourViewController alloc] initWithNibName:@"NumberFourViewController" bundle:nil] autorelease];

    tabBarController.viewControllers = [NSArray arrayWithObjects:numberOneViewController, numberTwoViewController,
                                        numberThreeViewController, numberFourViewController, nil];

    [self.navigationController pushViewController:tabBarController animated:YES];
A: 

self.view = tabBarController.view; in the viewDidLoad method of the TabBarController delegate class fixed it...

Ah well, surely someone else will run into the same thing and hopefully this will help them...

related questions