2009-09-25 6 views
1

Je suis en train de mon application comme si (en applicationDidFinishLaunching):iphone-dev: TabBarItem aide

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]; 

où s'étend MyTableController UITableController et possède une propriété de contrôleur de navigation. tabBarController est une sortie via le fichier nib principal. Il n'y a pas d'autres fichiers nib.

Je n'arrive plus à ajouter aucun bouton au contrôleur de navigation. Tout ce que je fais est ignoré. Qu'est-ce que je fais mal ici?

+0

'[[[MyTableController alloc] initWithStyle: UITableViewStylePlain] retain]': alloc fait déjà retenir. vous retenez trop – user102008

Répondre

0

Pouvez-vous inclure le code dans lequel vous avez configuré le UITabBarControllertabBarController? Je suppose que vous ne définissez pas correctement la propriété viewControllers. Utilisez UITabBarController -setViewControllers:animated: avec un tableau de contrôleurs de vue pour initialiser le contrôleur de la barre d'onglets.

Essayez quelque chose comme ceci:

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];