iphone - 动态替换 TabBar 项

标签 iphone ios uitabbarcontroller uitabbar uitabbaritem

我有一个带有两个 UIViewControllers 的 UITabBarController,例如“所有消息”、“收藏消息”。

对于某些操作,我需要用新的(其他操作,其他图像)动态替换我的 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]

谢谢

最佳答案

您可以在您的 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];

关于iphone - 动态替换 TabBar 项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10429821/

相关文章:

ios - 标签栏 Controller 中多个标签的一个导航 Controller

iphone - 选项卡栏 Controller ( Storyboard模板)和 AppDelegate

iphone - 将 NSString 从 NSMutableArray 连接到 NSString

ios - DismissViewController swift

ios - 如何在导航栏上添加自定义 View

ios - 如何使用 popupdialogue 从弹出 Controller 中关闭弹出窗口?

ios - 使用 AVQueuePlayer 时如何在视频之间添加转场?

ios - 如何通过 UITabBarController 将 indexPathForSelectedRow 传递到 UITabView?

iphone - NSArray 中的对象数

php - 如何将带有xml的url请求发送到php页面