Skip to content

Instantly share code, notes, and snippets.

@edwardinubuntu
Created June 25, 2014 06:42
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 edwardinubuntu/df555ae8feec5f8d12ec to your computer and use it in GitHub Desktop.
Save edwardinubuntu/df555ae8feec5f8d12ec to your computer and use it in GitHub Desktop.
How to calculate cell height.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
LHIdeaGroupCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IdeaGroupCell"];
CGFloat labelWidth = cell.descriptionLabel.width;
LHIdeaGroup *currentGroup = [self.objects objectAtIndex:indexPath.row];
CGRect r = [currentGroup.Description boundingRectWithSize:CGSizeMake(labelWidth, 0)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName: cell.descriptionLabel.font}
context:nil];
return r.size.height + 60.f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment