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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:44:28+00:00 2026-06-13T19:44:28+00:00

Currently when scrolling upwards in my tableView I have found a strange and annoying

  • 0

Currently when scrolling upwards in my tableView I have found a strange and annoying bug. When I decide to release the “scroll”, meaning I am dropping “the scroll” so the “View” will return to its normal position showing all of the TableView’s content, some of my cell’s can for some reason re-size themselves on the width. I have no clue why this occur or what the problem might be.

My cell’s (commentLabel) are customized to fitSize depending on the height of the label in my forum. I assume the problem may be in how I am trying to customize my cell’s content. I will post my relevant code and also post to pictures below.

Before starting to drag the scroll upwards: http://tinypic.com/view.php?pic=2rfsum9&s=6

After release/droped the scroll again to its normal position. Now one of the cell’s changed: http://tinypic.com/view.php?pic=swxnqv&s=6

Code:

- (UITableViewCell *)tableView:(UITableView *)pTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"ForumthreadCell";
    UITableViewCell *cell = [pTableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    Feedback *item = [self.items objectAtIndex:indexPath.row];

    UILabel *aliasLabel = (UILabel *)[cell viewWithTag:1];
    UILabel *commentLabel = (UILabel *)[cell viewWithTag:2];
    UILabel *dateLabel = (UILabel *)[cell viewWithTag:3];

    [aliasLabel setText:item.alias];
    [commentLabel setText:item.comment];
    [dateLabel setText:[self.dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:(double)item.time]]];

    commentLabel.numberOfLines = 0;
    [commentLabel sizeToFit];

    return cell;

}

-(CGFloat)getLabelHeightForText:(NSString *)text andWidth:(CGFloat)labelWidth
{

    CGSize maximumSize = CGSizeMake(labelWidth, 10000);

    //provide appropriate font and font size
    CGSize labelHeighSize = [text sizeWithFont: [UIFont fontWithName:@"Trebuchet MS" size:12.0f]
                     constrainedToSize:maximumSize
                         lineBreakMode:UILineBreakModeTailTruncation];
    return labelHeighSize.height;

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    Feedback *item = [self.items objectAtIndex:indexPath.row];

    CGFloat commentTextHeight = [self getLabelHeightForText:item.comment andWidth:162];
    return commentTextHeight + 39;

}

EDIT

The new code:

CGRect frame = commentLabel.frame;
frame.size.width = kLabelWidth;
frame.size.height = 10000;
commentLabel.frame = frame;

frame = commentLabel.frame;
frame.size.height += kOffset;
commentLabel.frame = frame;

But I have done something wrong since now the text from the commentLabel is not getting displayed correctly, can anyone se my fault here in how I try to set the frame? This is what the cell’s look like now http://oi50.tinypic.com/2w5u0s6.jpg

The new full code:

static const CGFloat kLabelWidth = 162;
static const CGFloat kOffset = 39;

- (UITableViewCell *)tableView:(UITableView *)pTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"ForumthreadCell";
    UITableViewCell *cell = [pTableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    Feedback *item = [self.items objectAtIndex:indexPath.row];

    UILabel *aliasLabel = (UILabel *)[cell viewWithTag:1];
    UILabel *commentLabel = (UILabel *)[cell viewWithTag:2];
    UILabel *dateLabel = (UILabel *)[cell viewWithTag:3];

    [aliasLabel setText:item.alias];
    [commentLabel setText:item.comment];
    [dateLabel setText:[self.dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:(double)item.time]]];

    CGRect frame = commentLabel.frame;
    frame.size.width = kLabelWidth;
    frame.size.height = 10000;
    commentLabel.frame = frame;

    frame = commentLabel.frame;
    frame.size.height += kOffset;
    commentLabel.frame = frame;

    commentLabel.numberOfLines = 0;
    [commentLabel sizeToFit];

    return cell;

 }
  • 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-13T19:44:30+00:00Added an answer on June 13, 2026 at 7:44 pm

    You should adjust label frames before reusing cells. In your case you are changing cells height while reusing it in

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    

    but you should also adjust label’s frame according to cell’s height so that it will not go beyond cell’s bound.

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

Sidebar

Related Questions

I currently have a scrolling anchor animation that also adds an active class to
I currently have a GridView scrolling vertically, and everything works fine. But now that
I'm currently working on an iPad JS/HTML app, using native scrolling to view a
I have a scrolling div containing list items. I have this boilerplate scroll event
I am currently creating a scrolling slideshow from scratch, and have run into a
Currently i have a UIDocumentaionInteractionController to view the PowerPoint (.ppt) file. I can able
I currently am using a UIScrollView to work as a way of scrolling/ dragging
Currently, I'm working on a project where I have a server - client relationship
Currently I have 2 ways of displaying images in a cell, which way will
Currently I'm trying to make some sort of vertical auto-scrolling. This is my code

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.