views:

292

answers:

1

Hi,

I have am setting up my application like so (in applicationDidFinishLaunching):

mytable = [[[MyTableController alloc] initWithStyle:UITableViewStylePlain] retain];

UINavigationController *mynav =  [[[UINavigationController alloc]initWithRootViewController:mytable] autorelease];

[mynav.view setFrame:CGRectMake(0,0,320,460)];

UIViewController *tab1 = [[tabBarController viewControllers] objectAtIndex:0];

[mytable setTitle:@"Chronological"];

mytable.navigationController = mynav;

[tab1.view addSubview:mynav.view];

[window addSubview:tab1.view];

where MyTableController extends UITableController and has a navigation controller property. tabBarController is an outlet via the main nib file. There are no other nib files.

I am now unable to add any buttons to the navigation controller. Everything I do is ignored. What am I doing wrong here?

A: 

Can you include the code where you set up the UITabBarController tabBarController? I'm guessing that you are not properly setting the viewControllers property. Use UITabBarController -setViewControllers:animated: with an array of view controllers to initialize the tab bar controller.

Try something like this:

mytable = [[MyTableController alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *mynav = [[UINavigationController alloc] initWithRootViewController:mytable];
[tabBarController setViewControllers:[NSArray arrayWithObject:mynav] animated:NO];
[mynav release];
[mytable release];
[tabBarController viewWillAppear:NO];
[window addSubview:[tabBarController view]];
[tabBarController viewDidAppear:NO];
pix0r