2010-01-23 56 views
2

我正在開發一個帶有5個選項卡的iPhone標籤欄應用程序。如何更改tabbar控制器應用程序中選項卡的數量?

我想顯示在啓動時,如一個是「找到我」只有兩個選項卡。

當用戶輕敲定位我標籤另一3個標籤將被顯示在與可以使用的當前位置。

我想做一些像「都市勺子」的東西。

我正在使用所有的東西的界面生成器。

如果任何人有任何想法,建議,鏈接,然後提供給我。

謝謝 。

回答

3
// Make array which includes your existing view controllers 
NSMutableArray *newVCs = [NSMutableArray arrayWithArray:[yourTabBarController viewControllers]]; 

// First new VC you want to add (example from a nib) 
[newVCs addObject:[[[SomeCustomViewController alloc] initWithNibName:@"yourNibName" bundle:[NSBundle mainBundle]] autorelease]]; 

// Second new VC you want to add (example for a VC generated from code) 
[newVCs addObject:[[[AnotherCustomViewController alloc] initWithNibName:nil bundle:nil] autorelease]]; 

// Third new VC you want to add (example from IBOutlet) 
[newVCs addObject:self.yetAnotherViewController]; 

// Set the tab bar's view controllers to your new modified array 
[yourTabBarController setViewControllers:newVCs]; 
4

-[UITabBarController setViewControllers:] =>您可以給標籤欄控制器一個新的視圖控制器陣列,它將用新的標籤替換其新的標籤,這些標籤對應於新陣列中的視圖控制器。

+0

你可以給我示例代碼或任何例子鏈接。我搜索了很多,但無法找到。 – harshalb 2010-01-23 05:39:21

相關問題