1

我有一个带有两个 UIViewController 的 UITabBarController fe“所有消息”,“最喜欢的消息”。

对于某些操作,我需要用新的(其他操作,其他图像)动态替换我的 UITabBar 项目......

所以它应该是“喜欢”和“不喜欢”而不是“所有消息”、“最喜欢的消息”。

最好的方法是什么?

// Note
//I don't need ViewControllers for these items, I will use TabBar delegate
//so I can't do following:
tabBarVC.viewControllers = [NSArray ...new view controllers]

谢谢

4

3 回答 3

0

您可以在 tabbarselect 方法中使用此代码

 if(tabbar.selectedindex==1)
 {
  self.title=@"newtitle"
 }

像这样

 UITabBarController *tabbar1 = [[UITabBarController alloc] init];


secondviewcontroller  *second = [[secondviewcontroller alloc] initWithNibName:nil bundle:nil];
second.title=@"message";

firstviewcontroller *third=[[firstviewcontroller alloc]initWithNibName:nil bundle:nil];
third.title=@"all message";

   if(tabbar1.selectedindex==0)
 {
 second.title=@"like";
  third.title=@"DisLike";
 }

tabbar1.viewControllers = [NSArray arrayWithObjects: second,third,nil]; 
tabbar1.view.frame=CGRectMake(0, 0, 320, 460);
[self.view addSubview:tabbar1.view];
于 2012-05-03T10:59:30.580 回答
0

此示例显示删除当前选定的选项卡栏项目。

NSMutableArray* newArray = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
[newArray removeObject:self];
[self.tabBarController setViewControllers:newArray animated:YES];

tabbar items array和调用进行更改setviewcontrollers

于 2012-05-03T11:27:28.000 回答
0

来自UITabBarController文档

要配置选项卡栏控制器的选项卡,请将为每个选项卡提供根视图的视图控制器分配给 viewControllers 属性。

你可以做的只是暂时隐藏tabBarController的工具栏并UIToolbar使用你的选项在它的位置创建一个新的

于 2012-05-03T10:53:55.357 回答