UITableViewCell with variable height
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