实际上,问题出在问题标题中。问题是我需要在我的应用程序中更改 UITabBarController 的活动选项卡。我通过以下方式做到这一点:
[self.tabBarController setSelectedIndex:2]; //2 is just for instance
奇怪的是它确实改变了选定的选项卡,但该选项卡的标题颜色仍然保持不变(灰色),我希望它变成白色,就像我点击选项卡一样。你有什么建议吗?
编辑:
这是设置标签栏初始状态的代码:
UITabBarController *mvc = [[UITabBarController alloc]init];
AccountManagmentViewController *accountvc = [[AccountManagmentViewController alloc]init];
ListTableViewController *ltvc = [[ListTableViewController alloc]init];
UINavigationController *listNavcon = [[UINavigationController alloc]initWithRootViewController:ltvc];
CalendarViewController *calendarvc = [[CalendarViewController alloc]init];
UINavigationController *calendarNavcon = [[UINavigationController alloc]initWithRootViewController:calendarvc];
ListsManagerViewController *listsManager = [[ListsManagerViewController alloc]init];
UINavigationController *listsNavcon = [[UINavigationController alloc]initWithRootViewController:listsManager];
SettingsViewController *settings = [[SettingsViewController alloc]init];
UINavigationController *settingsNav = [[UINavigationController alloc]initWithRootViewController:settings];
[accountvc.tabBarItem setFinishedSelectedImage:[[EasyUITheme currentTheme]tabBarUserIconImageActive:YES] withFinishedUnselectedImage:[[EasyUITheme currentTheme]tabBarUserIconImageActive:NO]];
[listsNavcon.tabBarItem setFinishedSelectedImage:[[EasyUITheme currentTheme]tabBarListsIconImageActive:YES] withFinishedUnselectedImage:[[EasyUITheme currentTheme]tabBarListsIconImageActive:NO]];
[calendarNavcon.tabBarItem setFinishedSelectedImage:[[EasyUITheme currentTheme]tabBarCalendarIconImageActive:YES] withFinishedUnselectedImage:[[EasyUITheme currentTheme]tabBarCalendarIconImageActive:NO]];
[listNavcon.tabBarItem setFinishedSelectedImage:[[EasyUITheme currentTheme]tabBarMain10IconImageActive:YES] withFinishedUnselectedImage:[[EasyUITheme currentTheme]tabBarMain10IconImageActive:NO]];
[settings.tabBarItem setFinishedSelectedImage:[[EasyUITheme currentTheme]tabBarSettingsIconImageActive:YES] withFinishedUnselectedImage:[[EasyUITheme currentTheme]tabBarSettingsIconImageActive:NO]];
[accountvc.tabBarItem setTitle:NSLocalizedString(@"Account", nil)];
[listsNavcon.tabBarItem setTitle:NSLocalizedString(@"Lists", nil)];
[calendarNavcon.tabBarItem setTitle:NSLocalizedString(@"Calendar", nil)];
[listNavcon.tabBarItem setTitle:NSLocalizedString(@"Words", nil)];
[settings.tabBarItem setTitle:NSLocalizedString(@"Settings", nil)];