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 7523145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:42:39+00:00 2026-05-30T02:42:39+00:00

When I call [table reloaddata]; The cells get redrawn with new data, but my

  • 0

When I call [table reloaddata];

The cells get redrawn with new data, but my UILabels get messed up because they are drawn over the old UILabels, so its a mess.

    static NSString* PlaceholderCellIdentifier = @"PlaceholderCell";

UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:PlaceholderCellIdentifier];


if (cell == nil)
{
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:PlaceholderCellIdentifier] autorelease];   
    cell.detailTextLabel.textAlignment = UITextAlignmentCenter;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;


    cell.contentView.backgroundColor = [UIColor clearColor];
}

Is my Init of the cell.

I add a UILabel like so

        UILabel *theDateLabel = [[UILabel alloc] initWithFrame:CGRectMake(140, 35,140, 20)];
    [theDateLabel setBackgroundColor:[UIColor clearColor]];
    [theDateLabel setTextColor:[UIColor lightGrayColor]];
    [theDateLabel setText:[dateFormatter stringFromDate:theDate]];
    [theDateLabel setFont:[UIFont fontWithName:@"TrebuchetMS-Bold" size:15]];
    [cell addSubview:theDateLabel];
    [theDateLabel release];

There are a few more labels in the cell, same thing.

What I would like to happen is that the old labels disappear from the cell so that they are no longer visible.

  • 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-30T02:42:41+00:00Added an answer on May 30, 2026 at 2:42 am

    You should not add theDateLabel as a subview of cell. You should add it as a subview of cell.contentView.

    As yuji suggests, one way to implement this is to create a subclass of UITableViewCell with a property for each custom subview. That way you can easily get to the date label of a reused cell to set its text for the new row.

    Another common approach is to use the tag property that every UIView has. For example:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        static NSString* PlaceholderCellIdentifier = @"PlaceholderCell";
        static const int DateLabelTag = 1;
    
        UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:PlaceholderCellIdentifier];
        if (!cell) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:PlaceholderCellIdentifier] autorelease];   
    
            UILabel *theDateLabel = [[UILabel alloc] initWithFrame:CGRectMake(140, 35,140, 20)];
            theDateLabel.tag = DateLabelTag;
            theDateLabel.backgroundColor = [UIColor clearColor];
            theDateLabel.textColor = [UIColor lightGrayColor];
            theDateLabel.font = [UIFont fontWithName:@"TrebuchetMS-Bold" size:15];
            [cell.contentView addSubview:theDateLabel];
            [theDateLabel release];
        }
    
        NSDate *theDate = [self dateForRowAtIndexPath:indexPath];
        UILabel *theDateLabel = [cell.contentView viewWithTag:DateLabelTag];
        theDateLabel.text = [dateFormatter stringFromDate:theDate];
    
        return cell;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to re-load a table every time some data I get from
var down=function(a,b){alert(a)} Array.prototype.sort.call(table.tBodies[0].childNodes,down) Array.prototype.sort.call([0,1,2,3],down) Why do I not get alerts from the first sort
I have a service that loads data into my table view. When the service
Specifically, how do you get the image subview from a uitableview cell? My table
I am using a plist file inorder to fill my table cells , now
I am trying to insert a new cell into a table view where the
How could I retrieve the system call address from /proc/kcore . I could get
I have two tables called ASI and Call and the data in the tables
I have some table cells displaying different time. I want the time to be
Hi I currently have a table view which is being filled via Core Data.

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.