当我在XCode 11.1中运行该应用程序时,未显示UITabbar未选择的项目,如图所示
UITabBarController *tController=[[UITabBarController alloc] init];
tController.tabBar.selectionIndicatorImage = [UIImage imageNamed:@"footerhover.png"];
[tController.tabBar addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bottombar.png"]]];
NSMutableArray *arr=[[NSMutableArray alloc] init];
ProfileViewController *pViewController=[[ProfileViewController alloc] initWithNibName:@"ProfileViewController" bundle:nil];
pViewController.tabBarItem.title=@"PROFILE";
pViewController.tabBarItem.image=[UIImage imageNamed:@"profile_white.png"];
pViewController.tabBarItem.tag = 1;
if ([[[UIDevice currentDevice] systemVersion] compare:@"5.0" options:NSNumericSearch] == NSOrderedAscending) {
}else{
[pViewController.tabBarItem setImage:[[UIImage imageNamed:@"profile.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[pViewController.tabBarItem setSelectedImage:[[UIImage imageNamed:@"profile_white.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
}
UINavigationController *nav1=[[UINavigationController alloc] initWithRootViewController:pViewController];
senderArray[0] = nav1;
[arr addObject:nav1];
tController.viewControllers=senderArray;
Tabbar在XCode 10.3 / IOS 12中正常工作。请提出任何解决此问题的解决方案。
预先感谢
您必须替换此行...
[tController.tabBar addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bottombar.png"]]];
...和...
[tController.view insertSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bottombar.png"]]
belowSubview:tController.tabBar];
addSubview
文档:
要添加的视图。添加后,此视图将出现在任何其他子视图的顶部。