Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Set TTTableMessageItemCell height dynamically based on its content #674

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/Three20UI/Sources/TTTableMessageItemCell.m
Expand Up @@ -87,8 +87,20 @@ - (void)dealloc {

///////////////////////////////////////////////////////////////////////////////////////////////////
+ (CGFloat)tableView:(UITableView*)tableView rowHeightForObject:(id)object {
// XXXjoe Compute height based on font sizes
return 90;
TTTableMessageItem* item = object;

CGFloat height = TTSTYLEVAR(tableFont).ttLineHeight + kTableCellVPadding*1.5;
if (item.caption) {
height += TTSTYLEVAR(font).ttLineHeight;
}
if (item.text) {
height += TTSTYLEVAR(font).ttLineHeight * kMessageTextLineCount;
}
if (item.imageURL) {
height = height > kDefaultMessageImageHeight ? height : kDefaultMessageImageHeight;
}

return height;
}


Expand Down