Created
October 7, 2015 11:33
-
-
Save lukaszmargielewski/1a799cab758938e16781 to your computer and use it in GitHub Desktop.
UITableView height auto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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