Skip to content

Instantly share code, notes, and snippets.

@palmerc
Last active August 29, 2015 13:55
Show Gist options
  • Save palmerc/8749976 to your computer and use it in GitHub Desktop.
Save palmerc/8749976 to your computer and use it in GitHub Desktop.
Is this the best way to get cell height with auto-layout?
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
WBSEpisode *episode = [self.episodes objectAtIndex:indexPath.row];
WBSFantorangenEpisodeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kFantorangenEpisodesTableViewCellReuseIdentifier];
cell.episode = episode;
[cell setNeedsLayout];
[cell layoutIfNeeded];
CGFloat height = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
return height;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment