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

  • Home
  • SEARCH
  • 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 243663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:56:24+00:00 2026-05-11T20:56:24+00:00

For performance sake it is usual to reuse UITableView’ cells. Is there a way

  • 0

For performance sake it is usual to reuse UITableView’ cells.
Is there a way to do the same thing with TableView header’ views?
I am talking about the ones that are returned with delegate’s method:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

I tried to do the following which doesn’t seem to be working as expected:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    static NSString *CellIdentifier = @"Header";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
    if (cell == nil) {
        cell = [self getHeaderContentView: CellIdentifier];
    }
    return cell;
}

Is there a way to reuse header’ views?

  • 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-05-11T20:56:24+00:00Added an answer on May 11, 2026 at 8:56 pm

    The reason Apple built in the ability to reuse tableview cells is because while the tableview may have many rows, only a handful are displayed on screen. Instead of allocating memory for each cell, applications can reuse already existing cells and reconfigure them as necessary.

    First off, header views are just UIViews, and while UITableViewCell is a subclass of UIView, they are not intended to be placed as the view of a section header.

    Further, since you generally will have far fewer section headers than total rows, there’s little reason to build a reusability mechanism and in fact Apple has not implemented one for generic UIViews.

    Note that if you are just setting a label to the header, you can use -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section instead.

    For something more custom, such as a label with red text (or a button, image, etc), you can do something like this:

    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
      UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0,0, 320, 44)] autorelease];
      UILabel *label = [[[UILabel alloc] initWithFrame:headerView.frame] autorelease];
      label.textColor = [UIColor redColor];
      label.text = [NSString stringWithFormat:@"Section %i", section];
    
      [headerView addSubview:label];
      return headerView;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Criteria: Performance, Performance, Performance. I need a way to convert a uint, int, etc
Is there a performance difference between i++ and ++i if the resulting value is
Is there any performance difference between tuples and lists when it comes to instantiation
Is there a performance hit if we use a loop instead of recursion or
For academic and performance sake, given this crawl recursive web-crawling function (which crawls only
Is there any performance / memory hit differential among the three following styles? Exhibit
Strange performance outcome, I have a LINQ to SQL query which uses several let
Keeping performance on a mobile device in mind, what do you think is the
For performance reasons, I draw the strings for my UITableViewCell in a custom view
I knew of some performance reasons back in the SQL 7 days, but do

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.