Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Calculate height for a given row
- (CGFloat)tableView:(TUITableView *)tableView heightForRowAtIndexPath:(TUIFastIndexPath *)indexPath
{
CGFloat calcuatedHeight = 55.0;
NSDictionary *post = [_posts objectAtIndex:indexPath.row];
NSString *type = [post valueForKey:@"type"];
NSString *message = [post valueForKey:@"message"];
if (!message) message = type;
TUIAttributedString *s = [TUIAttributedString stringWithString:message];
[s setAlignment:TUITextAlignmentLeft lineBreakMode:TUILineBreakModeWordWrap];
s.color = [TUIColor blackColor];
s.font = [Crew crewFont];
CGFloat textHeight = [s ab_sizeConstrainedToWidth:200].height;
NSLog(@"%f", textHeight);
if (textHeight > calcuatedHeight) calcuatedHeight = textHeight;
return calcuatedHeight;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment