I have UITabBarone that functioned well before my upgrade to Xcode 7, and now I can’t understand what is happening to me. I tried several solutions, including a setting imageWithRenderingModefor each tab that I create, trying to change the background color UITabBarto see if the elements can only be white and update the icons themselves to new versions. My default tab is displayed very well, and then when I select another tab, text appears but no image. (Text is saved and changes to gray by default when you switch to another tab.)
I attached a screenshot of what I see, and this is how I implement tabs now.
The function of creating a scoreboard:
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];
}
:
- (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;
}
