2010-01-23 55 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

相关问题