2016-02-23 2 views
0

У меня есть UITabBar, который работает нормально, но когда я добавляю больше элементов, и чем больше кнопок появляется, тем больше странное поведение.moreNavigationController не отображает изображение на мгновение

Если я выберу один элемент, а затем вернусь, снова нажав кнопку «больше», выбранный элемент не покажет изображение в течение нескольких секунд, а затем снова отобразится.

Я разработал UITabBar программно, и я изменил UITableView для большего количества функцийNavigationController.

Если я удаляю персонализацию функции moreNavigationController, то это поведение.

Моей первой предположения был цвет оттенка UITabBar (белый), но я изменяю его на красный, и поведение такое же.

Тогда, хотя это было изображение, но невыбранное изображение серое, а выбранное изображение - синее.

Это код, который я использую для создания 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]; 
} 

И это, как я персонализировать UITableView в moreNavigationController:

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]; 
    } 
} 

На этом изображении вы может видеть, что происходит:

enter image description here

Заранее спасибо.

ответ

Смежные вопросы