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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:37:28+00:00 2026-05-23T02:37:28+00:00

im having troubles making my UILabel height dynamic. The label is contained in a

  • 0

im having troubles making my UILabel height dynamic. The label is contained in a custom TableViewCell

I have managed to make the TableViewCellHeight dynamic, but i cant make the label multiple lines.

Whenever i set number of lines = 0 (in IB as well as code), the label/text disappears completely. And lineBreakMode doesnt do much either?

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


    Book *eventUp = [appDelegate.eventDataUp objectAtIndex:indexPath.row];

    NSString *text = eventUp.date;

    CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f);

    CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];

    CGFloat height = MAX(size.height, 44.0f);

    return height + (CELL_CONTENT_MARGIN * 2);

    //return 66;    

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [appDelegate.eventDataUp count];
}



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

    static NSString *CellIdentifier = @"EventUpCVCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {

        self.eventUpCVCell = nil;
        [[NSBundle mainBundle] loadNibNamed:@"EventUpCVCell" owner:self options:nil];
        cell = self.eventUpCVCell;

        label = [[UILabel alloc] initWithFrame:CGRectZero];
        [label setLineBreakMode:UILineBreakModeWordWrap];
        [label setMinimumFontSize:FONT_SIZE];
        [label setNumberOfLines:0];
        [label setFont:[UIFont systemFontOfSize:FONT_SIZE]];
        [label setTag:1];

        [[cell contentView] addSubview:label];
         }
    Book *eventUp = [appDelegate.eventDataUp objectAtIndex:indexPath.row];

    UILabel *lblMonth = (UILabel *) [cell viewWithTag:kLabel1Tag];
    UILabel *lblTitle = (UILabel *) [cell viewWithTag:kLabel2Tag];
    UILabel *lblDate = (UILabel *) [cell viewWithTag:kLabel3Tag];

    //month.text = eventUp.month;
    lblTitle.text = eventUp.title;
    lblDate.text = eventUp.date;

    //lblDate.lineBreakMode = UILineBreakModeWordWrap;
    lblDate.numberOfLines = 1;

    lblMonth.text = [NSString stringWithFormat:@"%@ ", eventUp.month];



    //cell.textLabel.text = eventUp.title;

    //cell.detailTextLabel.text = eventUp.date;

    //NSLog(@"Hello");
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    // Set up the cell
    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-05-23T02:37:29+00:00Added an answer on May 23, 2026 at 2:37 am

    You have to set the label frame after creating it, actually you create it with CGRectZero Frame

    try:

           label = [[UILabel alloc] initWithFrame:CGRectZero];
            [label setLineBreakMode:UILineBreakModeWordWrap];
            [label setMinimumFontSize:FONT_SIZE];
            [label setNumberOfLines:0];
            [label setFont:[UIFont systemFontOfSize:FONT_SIZE]];
            [label setTag:1];
    
            Book *eventUp = [appDelegate.eventDataUp objectAtIndex:indexPath.row];
    
            NSString *text = eventUp.date;
    
            CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f);
    
            CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
    
            [label setFrame:CGRectMake(0,0,size.width,size.height)];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble making sense of the following: UILabel *label = (UILabel *)[cell viewWithTag:1000];
i have used observed_field for arrays of data... but i am having trouble making
I'm having troubles debugging a POST request I'm making from my web server to
I'm making a program in C, and I'mm having some troubles with memory, I
I'm having troubles on making the PHP cURL library recognize the alias I created
I'm having trouble making this simple thing happen. I have this loop adding values
I'm having trouble making eclipse update the default icons and app name. I have
I'm using grep to extract parts from a file but I'm having trouble making
I making web games in java and having troubles each time when getting to
I am using a plugin called jQuery contextMenu but am having trouble making it

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.