Is it possible to have different cells to be different heights? In my tableView, I want to have cells adjust to how long the text within them is. So a cell with not much text will be the default height, but a cell with a lot of text in it will be wider so that it can show all the text in it. Is this possible?
+1
A:
Yes you can I'm doing something very similar in one of my own apps using the following, hope this helps
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *message = [log objectAtIndex:indexPath.row];
CGSize size = [message sizeWithFont:[UIFont systemFontOfSize:12] constrainedToSize:CGSizeMake(320.0f, 480.0f) lineBreakMode:UILineBreakModeWordWrap];
return size.height + 15;
}
acqu13sce
2010-10-11 01:16:52
Just be aware that implementing this delegate method makes the tableView call it for every cell, every time it redraws any part of the table, so it can really kill performance, especially for tables with ~1000 or more rows.
Kelan
2010-10-11 01:43:15