Skip to content

Instantly share code, notes, and snippets.

@mrjjwright
Created August 20, 2011 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrjjwright/1159482 to your computer and use it in GitHub Desktop.
Save mrjjwright/1159482 to your computer and use it in GitHub Desktop.
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