2009-09-25 46 views
1

我有我(在的applicationDidFinishLaunching)的设置我的应用程序,像这样:iphone-dev的:TabBarItem帮助

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

其中MyTableController延伸UITableController并具有导航控制器属性。 tabBarController是通过主要nib文件的插座。没有其他的nib文件。

我现在无法将任何按钮添加到导航控制器。我所做的一切都被忽略了。我在这里做错了什么?

+0

'[[[MyTableController页头] initWithStyle:UITableViewStylePlain]保留]':页头已经做了保留。你保留得太多 – user102008 2010-12-03 23:31:08

回答

0

您可以在其中设置代码:UITabBarControllertabBarController?我猜你没有正确设置viewControllers属性。使用UITabBarController -setViewControllers:animated:和一系列视图控制器来初始化标签栏控制器。

尝试是这样的:

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