Jump to content

- - - - -

Refresh my Header Section

  • Please log in to reply
2 replies to this topic

#1 jimijon


    Jr. Member

  • STV 4.0 Std
  • PipPip
  • 25 posts
Reputation: 2

Posted 10 February 2014 - 05:56 PM

How do I get my header cell to refresh?

SCTableViewSection *section = [SCTableViewSection section];
        NSArray *elementsInNib = [[NSBundle mainBundle] loadNibNamed:@"TB_PortfolioTileEditHeaderCell" owner:Nil options:nil];
        TB_PortfolioSectionHeaderCell *headerCell = [elementsInNib lastObject];

        headerCell.labelDisplayCurrency.text = self.portfolioTile.portfolio.currency;
        headerCell.labelDisplayName.text =;

        NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
        [numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
        [numberFormatter setRoundingMode:NSNumberFormatterRoundHalfUp];
        [numberFormatter setSecondaryGroupingSize:2];
        [numberFormatter setRoundingIncrement:[NSNumber numberWithDouble:0.001]];
        [numberFormatter setMaximumFractionDigits:2];
        [numberFormatter setMinimumFractionDigits:2];

        headerCell.labelDisplayMarketValue.text = [numberFormatter stringFromNumber:self.portfolioTile.marketValue];
        headerCell.labelDisplayQuantity.text = [numberFormatter stringFromNumber:self.portfolioTile.totalQuantity];
        headerCell.labelDisplayCost.text = [numberFormatter stringFromNumber:self.portfolioTile.totalCost];
        headerCell.labelDisplayProfit.text = [numberFormatter stringFromNumber:self.portfolioTile.profit];
        headerCell.labelDisplaySymbol.text = self.portfolioTile.tile.symbol;
        headerCell.labelDisplayName.text =;
        headerCell.labelDisplayLastPrice.text = [numberFormatter stringFromNumber:self.portfolioTile.tile.lastPrice];
        headerCell.labelDisplayPriceChange.text = [numberFormatter stringFromNumber:self.portfolioTile.tile.priceChange];

        section.headerView = headerCell;
        [self.tableViewModel addSection:section];



then I try:


        transactionsSection.sectionActions.didInsertItem = ^(SCArrayOfItemsSection *itemsSection, NSObject *item, NSIndexPath *indexPath)
           [context MR_saveToPersistentStoreAndWait];
           [section reloadBoundValues];
          // [self.tableViewModel.modeledTableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];

If I uncomment out the reloadSections then it goes blank my cell.


#2 ozie



  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169

Posted 10 February 2014 - 06:25 PM

headers of UITableViews only refresh when the table is reloaded, same as footers

you have to either reload the tableview, or create a custom header that uses a uilabel and then change the labels text


what if you try changing your last piece of code and add this instead

[itemsSection.ownerTableViewModel.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];

i see that your using self in block code.. this is not good as it creates a retain cycle..

plus you has modeledTableView instead of just plain tableView..

so you don't have to create a weak self reference i used the itemsSection to get hold of its owner

  • David DelMonte likes this

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.

#3 jimijon


    Jr. Member

  • STV 4.0 Std
  • PipPip
  • 25 posts
Reputation: 2

Posted 11 February 2014 - 08:17 AM

Used the UILabel approach and just reset the values there in didInsertItem.


Thanks about "self" there... I get a little sloppy when I am empirically learning stuff.

  • David DelMonte likes this

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users