如何更改tabbar控制器应用程序中的选项卡数量?

时间:2010-01-23 04:57:48

标签: iphone uitabbarcontroller

我正在开发一个带有5个标签的iPhone标签栏应用程序。

我想在发布时只显示两个标签,例如“找到我”。

当用户点击找到我标签时,将显示另外3个标签,并且可以使用当前位置。

我想做一些像“都市勺子”的事情。

我正在使用界面构建器来处理所有内容。

如果有人有任何想法,建议,那么链接就会提供给我。

由于

2 个答案:

答案 0 :(得分:4)

-[UITabBarController setViewControllers:] =>您可以为标签栏控制器提供一个新的视图控制器数组,它将使用与新数组中的视图控制器对应的新选项卡替换其现有选项卡。

答案 1 :(得分: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];