• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
UITableViewCell with variable height
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

UITableViewCell with variable height


  • Subject: UITableViewCell with variable height
  • From: Koen van der Drift <email@hidden>
  • Date: Sun, 28 Apr 2013 14:57:03 -0400

I'm having some problems to resize and show all text in a UITableViewCell based on the contents. It has two labels, the second of which can have a variable length and I'd like to show it all.

So I added this code:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    Note *n = [self.notes objectAtIndex: [indexPath row]];

    CGSize constraint = CGSizeMake(320, 2000.0f);
    CGSize size = [n.content sizeWithFont: [UIFont systemFontOfSize: 14.0f]
                         constrainedToSize: constraint
                             lineBreakMode: NSLineBreakByWordWrapping];

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

    return height + 44.0f;
}


The problem is that the height of the cell is changing, but it still shows only one line of the second label. I have also set the numberOfLines to 0, which according to the docs "To remove any maximum limit, and use as many lines as needed, set the value of this property to 0."

How can I fix this?

Thanks,

- Koen.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: UITableViewCell with variable height
      • From: Ten Horses | Diederik Meijer <email@hidden>
  • Prev by Date: Re: Is FSEvents more efficient than polling?
  • Next by Date: Re: UITableViewCell with variable height
  • Previous by thread: Re: Is FSEvents more efficient than polling?
  • Next by thread: Re: UITableViewCell with variable height
  • Index(es):
    • Date
    • Thread