UITabbar项目在升级到Xcode 7之后单击之前不显示

Jak*_*sby 7 xcode objective-c uitabbar ios

UITabBar在升级到Xcode 7之前,我有一个运行良好的功能,现在我无法弄清楚我生活中发生了什么.我尝试了几种解决方案,包括imageWithRenderingMode为我创建的每个选项卡设置,尝试更改背景颜色UITabBar以查看是否可能只是白色的项目,并将图标本身更新为新版本.我的默认选择选项卡显示正常,然后当我选择另一个选项卡时,文本显示,但没有图像.(当移动到另一个选项卡时,文本仍然存在并更改为默认灰色.)

我附上了我所看到的截图,这就是我目前正在实现tabbar的方式.

创建tabbar的功能:

void MakeTabBar(id target)
{
    PFUser *currentUser = [PFUser currentUser];

    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    appDelegate.recentView = [[RecentView alloc] init];
    appDelegate.groupsView = [[GroupsView alloc] init];
    appDelegate.settingsView = [[SettingsView alloc] init];
    appDelegate.homeView = [[HomeView alloc] init];

    NavigationController *navController1 = [[NavigationController alloc] initWithRootViewController:appDelegate.recentView];
    NavigationController *navController2 = [[NavigationController alloc] initWithRootViewController:appDelegate.groupsView];
    NavigationController *navController4 = [[NavigationController alloc] initWithRootViewController:appDelegate.settingsView];
    NavigationController *navController5 = [[NavigationController alloc] initWithRootViewController:appDelegate.homeView];

    appDelegate.tabBarController = [[UITabBarController alloc] init];
    appDelegate.tabBarController.tabBar.translucent = NO;
    appDelegate.tabBarController.selectedIndex = DEFAULT_TAB;
    [[UITabBar appearance] setTintColor:COLOR_OUTGOING];

    NSMutableDictionary *customAttributes = [NSMutableDictionary dictionary];
    BOOL isAdmin = [currentUser[@"isAdmin"] boolValue];
    if(isAdmin){
        [customAttributes setObject:currentUser[@"isAdmin"] forKey:@"isAdmin"];
        appDelegate.peopleView = [[PeopleView alloc] init];
        NavigationController *navController3 = [[NavigationController alloc] initWithRootViewController:appDelegate.peopleView];
        appDelegate.tabBarController.viewControllers = @[navController5, navController1, navController2, navController3, navController4];
    } else{
        appDelegate.tabBarController.viewControllers = @[navController5, navController1, navController2, navController4];
    }

    BOOL isTester = [currentUser[@"isTestData"] boolValue];
    if(isTester){
        [customAttributes setObject:currentUser[@"isTestData"] forKey:@"isTestData"];
    }

    [appDelegate.window setRootViewController:appDelegate.tabBarController];
}
Run Code Online (Sandbox Code Playgroud)

每个视图中的代码创建选项卡:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    {
        [self.tabBarItem setImage:[UIImage imageNamed:@"tab_consultants"]];
        self.tabBarItem.title = @"Consultants";
    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Jak*_*sby 8

经过大量的反复试验,我发现问题是由于导航控制器和我的标签栏包含在我的UINavigation中,其颜色不同以支持顶部导航栏.我将它们分开了,现在它按预期工作了.