gpt4 book ai didi

ios - UITabBarController 最初突出显示所有选项卡栏项目图像

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:43:04 24 4
gpt4 key购买 nike

我正在以编程方式实例化一个将管理 2 个 View Controller 的 UITabBarController,然后将其设置为 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;

enter image description here

最佳答案

我遇到了同样的问题,这是因为我调用:

[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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com