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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:20:00+00:00 2026-05-23T21:20:00+00:00

I am writing an iOS app for a client, the main view is a

  • 0

I am writing an iOS app for a client, the main view is a table view, and i fill the cells with text, much like most iOS twitter clients.

I have created a custom cell view with 3 labels, and i fill these labels with the texts. One of the labels needs to resize automatically depending on the amount of text there is (maximum of 140 characters).

This works fine until i scroll up/down the list when the text either extends to a single full line (like the label has expanded) OR only takes up part of the space so it ends up deeper and overflowing into other labels (i do have “Clip Subviews” enabled as per another similar SO question)

So when the table and its data is first loaded the screen looks like:

before scrolling http://lloydsparkes.co.uk/files/iOS-BeforeScrolling.png

And after a bit of scrolling it looks like:

after scrolling http://lloydsparkes.co.uk/files/iOS-AfterScrolling.png

So it seems that the label is resizing during the scrolling (maybe due to the same cell being reused?) and not resizing back to the correct size.

My code for filling a cell is:

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

static NSString *myID = @"customCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:myID];

if(cell == NULL) {

    [[NSBundle mainBundle] loadNibNamed:@"CustomCellView" owner:self options:nil];

    cell = customCell;
    self.customCell = nil;
}

Post *p = [posts objectAtIndex:indexPath.row];

UILabel *label = (UILabel*)[cell viewWithTag:15];
label.text = p.Name;

label = (UILabel*)[cell viewWithTag:10];
label.text = p.Text;
[label sizeToFit];

label = (UILabel*)[cell viewWithTag:20];
label.text = [p Source];

//[cell layoutSubviews];

return cell;
}

So what i am asking is, what is causing this problem? and how can it be solved?

  • 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-23T21:20:02+00:00Added an answer on May 23, 2026 at 9:20 pm

    The sizeToFit method might be behaving in a weird way because the UILabel frame is changed every time cellForRowAtIndexPath is called.

    One thing you can try is setting the frame of the label object back to the original size (the valeu set in the NIB file) right before calling sizeToFit

    [label setFrame:CGRectMake(0.0f, 0.0f, 100.0f, 50.0f)];    
    [label sizeToFit];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an iOS app with a table view inside a tab view. In
I'm writing an iOS app which needs to generate and animate individual text characters
I'm writing a simple iOS App to manage Email address, maybe like Contacts. I
For an ios app I'm writing, I'd like to take an photo from the
I am writing an enterprise client/server application. The client is an iOS app which
Good day, I am writing an iOS app that needs to authenticate with Twitter.
I have many view controllers on my iOS app and in most of them
I'm writing a universal iOS app that a text entry component to it. When
I am writing an iOS app that uses live audio analysis. It has an
I am writing a network class for an iOS app. This class will take

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.