Skip to content

Instantly share code, notes, and snippets.

@lukaszmargielewski
Created October 7, 2015 11:33
Show Gist options
  • Save lukaszmargielewski/1a799cab758938e16781 to your computer and use it in GitHub Desktop.
Save lukaszmargielewski/1a799cab758938e16781 to your computer and use it in GitHub Desktop.
UITableView height auto
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath isOffscreen:YES];
cell.bounds = CGRectMake(0.0f, 0.0f, CGRectGetWidth(tableView.bounds), 10000);
[cell updateConstraintsIfNeeded];
[cell layoutIfNeeded];
CGFloat heightText = cell.shows_lower_panel ? CGRectGetMaxY(cell.countImageView.frame) : MAX(CGRectGetMaxY(cell.circleImageView.frame), CGRectGetMaxY(ccc.titleLabel.frame));
CGFloat height = heightText + cell.topConstraint.constant;
return height;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment