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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:48:05+00:00 2026-06-14T06:48:05+00:00

I have a UITable that I am expanding to show more info text. Problem

  • 0

I have a UITable that I am expanding to show “more info” text. Problem I have is the text can be varied sizes, i.e indexpath.section1 might be 1200 high where as index path.section2 is 300 high.

The code I have works fine until it comes to re-using the cell, the size of the label frame isnt adjusting for the new label. So although the cell is sized correctly the label inside that cell still has the original sized frame so if its too small the text gets cut off and I get loads of white space and if its too big then I cant see the text unless I scroll to the middle of the field.

What am I doing wrong?? any help please??

This is my code:-

            static NSUInteger const k1 = 1;

            // Declare references to the subviews which will display the data.
            UILabel *lbl1 = nil;

            static NSString *kCellID = @"CellID";

            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellID];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellID];

                if ((indexPath.section == 8) || (indexPath.section == 9) || (indexPath.section == 10) || (indexPath.section == 11) || (indexPath.section == 12) || (indexPath.section == 13) || (indexPath.section == 14)|| (indexPath.section == 15) || (indexPath.section == 16))
                {
                    lbl1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 290, 200)];
                }

                else if ((indexPath.section == 4) || (indexPath.section == 5))
                {
                    lbl1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 290, 1200)];
                }
                lbl1.font = [UIFont fontWithName:@"Trebuchet MS" size:12.0f];
                lbl1.tag = k1;
                lbl1.textColor = [UIColor blackColor];
                lbl1.backgroundColor = [UIColor clearColor];
                lbl1.highlightedTextColor = [UIColor whiteColor];
                lbl1.opaque = NO;
                lbl1.adjustsFontSizeToFitWidth = TRUE;
                lbl1.numberOfLines = 0;

                lbl1.lineBreakMode = UILineBreakModeWordWrap;
                [cell.contentView addSubview:lbl1];

            } else {
                lbl1 = (UILabel *)[cell.contentView viewWithTag:k1];
            }

            cell.accessoryView.tag = indexPath.row;

            lbl1.text = [NSString stringWithFormat:@"%@", cellValue];

            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-14T06:48:07+00:00Added an answer on June 14, 2026 at 6:48 am

    You need to set the autoresizing mask on your label. This will cause it to be resized when its superview is resized. The appropriate setting would be:

    lbl1.autoresizingMask = UIViewAutoresizingFlexibleHeight;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a subview over my UITable that is used as a busy view.
I have a UITable View with a textfield that is editable right on the
I have a UITable that has a UISearchDisplayController . The UITable is less than
I have picture in my dropbox, which i need to show in Uitable view.
I have a UIViewController that has both a UITable and a UIView on it.
I have recently found that Matlab can use LaTeX character sequences. However, they only
I have a problem using the following code to set background of UITAbleview. Can
I have a matlab function that returns results in a uitable. There are 2
I have a bunch of uiviews and uitable views. How can I theme them
I have a UITable with few custom cells which contains text fields. However when

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.