Re: UITableViewCell with variable height
Re: UITableViewCell with variable height
- Subject: Re: UITableViewCell with variable height
- From: Ten Horses | Diederik Meijer <email@hidden>
- Date: Sun, 28 Apr 2013 21:28:13 +0200
Are you recalculating the size of the label as well? Using the same logic?
I worked on the very same thing yesterday and that got it to work.
In my case the label's content can be very large, with string length up to 120000 characters and I found out that a label's recalculated size doesn't work well if the string's length is larger than 20.000...
Op 28 apr. 2013, om 20:57 heeft Koen van der Drift <email@hidden> het volgende geschreven:
> 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
>
_______________________________________________
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