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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:52:03+00:00 2026-05-15T13:52:03+00:00

I am not sure why my UITableViewCell’s are repeating after the user scrolls? –

  • 0

I am not sure why my UITableViewCell’s are repeating after the user scrolls?

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

        static NSString *CellIdentifier = @"Cell";

     ChartlyCell *cell = (ChartlyCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
     if (cell == nil) {
      //cell = [[[ChartlyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
      cell = [[[ChartlyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier andDelegate:self] autorelease];
     }


     ChartlyObject *myChartlyObject;
     myChartlyObject = [self.items objectAtIndex:indexPath.row];

     cell.usernameLabel.text = myChartlyObject.userName;
     cell.bodyLabel.text = myChartlyObject.chart_message;
     [cell.messageLabel setText: myChartlyObject.chart_message];
     cell.timeLabel.text = [Utils toShortTimeIntervalStringFromStockTwits: myChartlyObject.created_at];
     [cell.chartImage loadImageFromURL:[NSURL URLWithString:myChartlyObject.imageThumbnail]];  

        return cell;
    }

This is how the cell is being created:

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier andDelegate:(id<NLabelDelegate>)ndelegate{
    if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
        // Initialization code
  CGRect rect;

  rect = CGRectMake(77, 5, 200, 20); //CGRectMake(10, 5, 200, 20);
  usernameLabel = [[UILabel alloc] initWithFrame:rect];
  //usernameLabel.backgroundColor = backgroundColor;
  usernameLabel.font = [Utils getBoldSystemFontWithSize:14];
  usernameLabel.textColor = [UIColor colorWithRed:.368 green:.741 blue:.784 alpha:1];
  [self.contentView addSubview: usernameLabel];

  rect = CGRectMake(277, 5, 38, 20);
  timeLabel = [[UILabel alloc] initWithFrame:rect];
  timeLabel.textAlignment = UITextAlignmentRight;
  //timeLabel.backgroundColor = backgroundColor;
  timeLabel.font = [Utils getBoldSystemFontWithSize:14];
  timeLabel.textColor = [UIColor colorWithRed:.98 green:.65 blue:.01 alpha:1];
  [self.contentView addSubview: timeLabel];

  /*rect = CGRectMake(77, 25, 238, 68); //CGRectMake(10, 50, 238, 68);
  bodyLabel = [[UILabel alloc] initWithFrame:rect];
  bodyLabel.font = [Utils getSystemFontWithSize:10];
  bodyLabel.numberOfLines = 3;
  bodyLabel.lineBreakMode = UILineBreakModeWordWrap;
  bodyLabel.textColor = [UIColor blackColor];
  bodyLabel.backgroundColor = [UIColor clearColor];
  [self.contentView addSubview: bodyLabel];*/

  rect = CGRectMake(77, 25, 238, 68);
  messageLabel = [[NLabel alloc] initWithFrame:rect andDelegate:ndelegate];
  [messageLabel setOpaque:NO];
  [messageLabel setBackgroundColor: [UIColor blackColor]];
  //[messageLabel setTotalheight:68];
  [self.contentView addSubview: messageLabel];

  rect = CGRectMake(13, 10, 48, 48);
  chartImage = [[AsyncImageView alloc]initWithFrame:rect];
  [self.contentView addSubview: chartImage];
    }
    return self;
}

UPDATE:
What is odd, is that if I uncomment the bodyLabel block and comment out the messageLabel block the repeating cells don’t appear anymore. I am not sure why and would still like to find a resolution

UPDATE #2
Only messageLabel gets repeated. All of the other labels do NOT repeat. Why is this?

  • 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-15T13:52:03+00:00Added an answer on May 15, 2026 at 1:52 pm

    Because you are re-using tablecells for proper memory management as you should be doing via dequeueReusableCellWithIdentifier 🙂 This way you don’t have a unique cell for every single cell you need. Instead you only have about 5 or 6 that get re-used over and over during scrolling.

    When the cell comes back into view, you need to reset the state (i.e. update the info, labels, images, etc) of each cell based on whatever cell came into view.

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

Sidebar

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.