我正在以编程方式实例化一个 UITabBarController ,它将管理 2 个 View Controller ,然后将其设置为 rootViewController 。但是,当 View 出现时,它会突出显示所有选项卡项的图像(尽管文本已正确突出显示)。无论我为 selectedIndex 设置什么,图像都会突出显示。只有当您点击标签栏项目时,它才会真正切换图像上的突出显示状态。这是怎么回事?
代码:
UITabBarController *tabController = [[UITabBarController alloc] init];
UIStoryboard *storyboard = [self storyboard];
OGVideoStreamViewController *questionsController = [storyboard instantiateViewControllerWithIdentifier"OGVideoStreamViewController"];
questionsController.isQuestion = YES;
OGVideoStreamViewController *answersController = [storyboard instantiateViewControllerWithIdentifier"OGVideoStreamViewController"];
answersController.isQuestion = NO;
OGMatchesViewController *matchesController = [[OGMatchesViewController alloc] initWithNibName"OGMatchesViewController" bundle:nil];
questionsController.tabBarItem = [[UITabBarItem alloc] initWithTitle"Questions" image:[UIImage imageNamed"Tab Icon - Questions"] tag:0];
answersController.tabBarItem = [[UITabBarItem alloc] initWithTitle"Answers" image:[UIImage imageNamed"Tab Icon - Answers"] tag:1];
matchesController.tabBarItem = [[UITabBarItem alloc] initWithTitle"Inbox" image:[UIImage imageNamed"Tab Icon - Inbox"] tag:2];
[tabController setViewControllers[questionsController, answersController, matchesController] animated:NO];
tabController.selectedViewController = questionsController;
[[UIApplication sharedApplication] keyWindow].rootViewController = tabController;
Best Answer-推荐答案 strong>
我也遇到了同样的问题,这是由于我打电话造成的:
[UIView appearance].tintColor = [UIColor colorWithRed:1.000
green:0.793
blue:0.236
alpha:1.000];
我在我的 AppDelegate 中调用了它,所以我可以将其更改为以下内容:
self.window.tintColor = [UIColor colorWithRed:1.000
green:0.793
blue:0.236
alpha:1.000];
关于ios - UITabBarController 最初突出显示所有标签栏项目图像,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/23861616/
|