moreNavigationController 瞬间不显示图像

moreNavigationController not displaying image for an instant

我有一个正常工作的 UITabBar,但是当我添加更多元素并且出现更多按钮时,它显示出一种奇怪的行为。

如果我 select 一个项目然后再次按 "more" 按钮返回,selected 项目在几秒钟内不显示图像然后显示再次.

我以编程方式创建了 UITabBar,并且以编程方式将 moreNavigationController 颜色的 UITableView 更改为。

如果我删除了 moreNavigationController 的个性化设置,那么行为就在那里。

我的第一个猜测是 UITabBar 的色调(白色),但我将其更改为红色并且行为相同。

然后我以为是图像,但未select编辑的图像是灰色的,select编辑的图像是蓝色的。

这是我用来创建 UITabBar 的代码:

- (void)createTabBar
{
    tabController = [self.storyboard instantiateViewControllerWithIdentifier:@"cCustomTabController"];
    dValue = [dConfiguration objectForKey:@"Buttons"];
    NSMutableArray  *aControllers = [[NSMutableArray alloc] init];
    int i = 0;
    for (NSString* sProperty in dValue) {
        NSString* d = @"Details";
        NetworkStatus internetStatus = [_reachabilityInfo currentReachabilityStatus];
        NSData *itemData = Nil;
        if (internetStatus != NotReachable)
            itemData = [util getSpecificJsonData:[sProperty valueForKeyPath:@"Item"]];
        if(itemData != nil){
            UIStoryboard *aStoryboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:[NSBundle mainBundle]];
            UIViewController *vcCustom = [aStoryboard instantiateViewControllerWithIdentifier:[util getControllerName:[sProperty valueForKeyPath:@"ViewController"]]];
            [vcCustom setValue:itemData forKey:@"JsonData"];
            [vcCustom setValue:[sProperty valueForKeyPath:@"Item"] forKey:@"Item"];
            [vcCustom setValue:d forKey:@"Details"];
            [util saveJSON:itemData withName:[NSString stringWithFormat:@"%@%@",[sProperty valueForKeyPath:@"Item"],[CommonsUtils getCommonUtil].getAppLanguage]];
            [[vcCustom navigationController] setNavigationBarHidden:NO animated:NO];
            vcCustom.navigationItem.leftBarButtonItem = Nil;
            vcCustom.navigationItem.hidesBackButton = YES;
            UIImage *imageBtn = [self changeImageSize:[UIImage imageNamed:[util getImageName:[sProperty valueForKeyPath:@"Image"] andRetrina:[sProperty valueForKeyPath:@"ImageRetina"]]] scaledToSize:CGSizeMake(30, 30)];
            UIImage *imageBtnPress = [self changeImageSize:[UIImage imageNamed:[util getImageName:[sProperty valueForKeyPath:@"ImageHeighlighted"] andRetrina:[sProperty valueForKeyPath:@"ImageRetinaHeighlighted"]]] scaledToSize:CGSizeMake(30, 30)];
            UITabBarItem *tab = [[UITabBarItem alloc] initWithTitle:[sProperty valueForKeyPath:@"Title"] image:imageBtn selectedImage:imageBtnPress];
            UIImage * iSelected = imageBtnPress;
            iSelected = [iSelected imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
            [tab setSelectedImage:iSelected];
            tab.tag = i;
            if([[sProperty valueForKeyPath:@"Title"] isEqualToString:@"Notificaciones"])
                tab.badgeValue=[sProperty valueForKeyPath:@"Badge"];
            [vcCustom setTabBarItem:tab];
            [vcCustom setTitle:[sProperty valueForKeyPath:@"Title"]];
            UINavigationController *navigationController = [[cCustomNavigationController alloc] initWithRootViewController:vcCustom];
            navigationController.navigationBar.tintColor = NAVBAR_TINTCOLOR;
            UIColor *uicText = NAVBAR_TEXTCOLOR;
            navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:uicText forKey:NSForegroundColorAttributeName];
            [aControllers insertObject:navigationController atIndex:i];
            i++;
        }
    }
    tabController.delegate = self;
    tabController.viewControllers = aControllers;
    tabController.tabBar.tintColor = TABBAR_TINTCOLOR;
    UIColor *uicTabBar = TABBAR_BACKGROUND_COLOR;
    [[UITabBar appearance] setBarTintColor:uicTabBar];

    tabController.customizableViewControllers = @[];
    tabController.moreNavigationController.navigationBar.tintColor = NAVBAR_TINTCOLOR;
    UIColor *uicText = NAVBAR_TEXTCOLOR;
    tabController.moreNavigationController.navigationBar.barTintColor = NAVBAR_BACKGROUND_COLOR;
    tabController.moreNavigationController.navigationBar.translucent = YES;
    tabController.moreNavigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:uicText forKey:NSForegroundColorAttributeName];
}

这就是我个性化 moreNavigationController 的 UITableView 的方式:

UITableView *tView = (UITableView*)tabController.moreNavigationController.topViewController.view;
if ([[tView subviews] count]) {
    for (UITableViewCell *cCell in [tView visibleCells]) {
        cCell.textLabel.textColor = TABLECELL_TEXT_COLOR;
        cCell.textLabel.highlightedTextColor = TABLECELL_TEXT_COLOR_HIGHLIGHTED;
        cCell.contentView.backgroundColor = TABLECELL_BACKGROUND_COLOR;
        cCell.backgroundColor = TABLECELL_BACKGROUND_COLOR;
        UIView * selectedBackgroundView = [[UIView alloc] init];
        UIColor *uicCell = TABLECELL_BACKGROUND_COLOR_SELECTED
        [selectedBackgroundView setBackgroundColor:uicCell];
        [cCell setSelectedBackgroundView:selectedBackgroundView];
    }
}

在这张图片中你可以看到发生了什么:

提前致谢。

正如我在这里看到的:

MoreNavigationController images disappearing on select

我已将这一行添加到我的代码中:

navigationController.tabBarItem = vcCustom.tabBarItem;

感谢您的帮助。