[英]UITabBarController initially highlights all tab bar item images
I'm programmatically instantiating a UITabBarController
that will manage 2 view controllers, and then setting it as the rootViewController
. 我正在以编程方式实例化将管理2个视图控制器的
UITabBarController
,然后将其设置为rootViewController
。 However when the views appear, it highlights all the tab item's images (although the text is properly highlighted). 但是,当视图出现时,它将突出显示选项卡项目的所有图像(尽管文本已正确突出显示)。 No matter what I set to the
selectedIndex
the images will all appear highlighted. 无论我为
selectedIndex
设置什么,图像都将突出显示。 Only when you tap on the tab bar items does it actually toggle the highlighted state on the images. 仅当您点击选项卡栏项目时,它才实际切换图像上的突出显示状态。 What's going on here?
这里发生了什么?
Code: 码:
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;
I've had the same problem and it was due to me calling: 我遇到了同样的问题,这是由于我打电话给我的:
[UIView appearance].tintColor = [UIColor colorWithRed:1.000
green:0.793
blue:0.236
alpha:1.000];
I called it in my AppDelegate, so i could change it to the following: 我在AppDelegate中调用了它,因此可以将其更改为以下内容:
self.window.tintColor = [UIColor colorWithRed:1.000
green:0.793
blue:0.236
alpha:1.000];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.