Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8406965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:15:31+00:00 2026-06-09T23:15:31+00:00

Hi hope someone can help. I currently have a tableview which has a set

  • 0

Hi hope someone can help.

I currently have a tableview which has a set of sections, in my titleForHeaderInSection i am returning a string that includes a sum of values contained in the section cells to display in the section header. This is fine but when i update a cell value i want the titleForHeaderInSection to update and refresh my sum of values. At the moment the user needs to scroll the header out of sight then back in for it to refresh. I have been googling to see if i could find a solution seen a few examples that suggest including a label in the view for header but i need the sections to be dynamic so cant create labels for each section, i have also tried using the reloadsection but this doesent work properly either and the tableview reloaddata is to much of a performance hit to do each time a value changes in a tableview cell.

my current code for my titlerForHeaderInSection is

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {

id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section];

int averageScoreTotal, _total;
averageScoreTotal = 0;
_total = 0;

for (BlkCon_BlockToConstructionType *sPC in sectionInfo.objects)
{
    _total = [sPC.compositionPc integerValue];

    averageScoreTotal += _total;
}   

return [NSString stringWithFormat: @"(Total Composition for Group %d)", averageScoreTotal];

}

Thanks in advance for any help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:15:33+00:00Added an answer on June 9, 2026 at 11:15 pm

    You can use UITableView’s -reloadSections:... method with the correct section. That will reload the section header, too.

    If you don’t want to use that method, because your table view stops scrolling for a moment or one of the table view cells is first responder, you have to use a custom header view for the section containing a label.

    1) Implement -tableView:heightForHeaderInSection: and -tableView:viewForHeaderInSection:

    - (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
        return tableView.sectionHeaderHeight;
    }
    
    - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
        CGFloat height = [self tableView:tableView heightForHeaderInSection:section];
        NSString *title = [self tableView:tableView titleForHeaderInSection:section];
    
        UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, height)];
        containerView.backgroundColor = tableView.backgroundColor;
    
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(19, 7, containerView.bounds.size.width - 38, 21)];
        label.backgroundColor = [UIColor clearColor];
    
        label.font = [UIFont boldSystemFontOfSize:17];
        label.shadowOffset = CGSizeMake(0, 1);
        label.shadowColor = [UIColor whiteColor];
    
        label.text = title;
        label.textColor = [UIColor colorWithRed:0.265 green:0.294 blue:0.367 alpha:1];
    
        [containerView addSubview:label];
    
        return containerView;
    }
    

    2) Update the label directly by changing its text property. You’ll have to create an iVar for the labels or better use an array to store them, so you can access them when you want to update the section header’s text.

    3) If you want to make the header flexible in height, set the numberOfLines property of the label to 0 so that it has indefinite lines and make sure the -tableView:heightForHeaderInSection: returns the correct height.

    In order to update the section header’s height use

    [self.tableView beginUpdates];
    [self.tableView endUpdates];
    

    Good luck,
    Fabian

    Edit:
    The code above assumes you’re using ARC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue which I hope someone can help me with. I'm able
I'm currently exploring django forms and have a issue I hope someone can help
hope someone can help with this. I currently have an Add to Cart option
I hope someone here can help me.. I am currently having a small issue
hope someone can help. I have two tables: Users -UserID -UserName UsersType -UserTypeID -UserID
I have a really hard time understanding routes and I hope someone can help
Really hope someone can help me as I'm a bit stuck :S I have
I hope someone can help with solution to this problem? Currently my ASP.Net MVC
Hope someone can help me. I have used the following tutorial as a guide
Hope someone can help i cant seem to get my head around this, i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.