2009-09-25 67 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];