我有一个带有两个 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/