diff --git a/Classes/UITableView+FDTemplateLayoutCell.m b/Classes/UITableView+FDTemplateLayoutCell.m index f21752b..fbdfdfd 100644 --- a/Classes/UITableView+FDTemplateLayoutCell.m +++ b/Classes/UITableView+FDTemplateLayoutCell.m @@ -79,13 +79,20 @@ - (CGFloat)fd_systemFittingHeightForConfiguratedCell:(UITableViewCell *)cell { [cell addConstraints:edgeConstraints]; } - [cell.contentView addConstraint:widthFenceConstraint]; +// [cell.contentView addConstraint:widthFenceConstraint]; // Auto layout engine does its math - fittingHeight = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height; +// fittingHeight = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height; // Clean-ups - [cell.contentView removeConstraint:widthFenceConstraint]; +// [cell.contentView removeConstraint:widthFenceConstraint]; + + CGSize fittingSize = UILayoutFittingCompressedSize; + fittingSize.width = CGRectGetWidth(self.frame); + fittingSize = [cell systemLayoutSizeFittingSize:fittingSize withHorizontalFittingPriority:UILayoutPriorityRequired verticalFittingPriority:UILayoutPriorityFittingSizeLevel]; + + fittingHeight = fittingSize.height; + if (isSystemVersionEqualOrGreaterThen10_2) { [cell removeConstraints:edgeConstraints]; } @@ -139,7 +146,7 @@ - (__kindof UITableViewCell *)fd_templateCellForReuseIdentifier:(NSString *)iden templateCell = [self dequeueReusableCellWithIdentifier:identifier]; NSAssert(templateCell != nil, @"Cell must be registered to table view for identifier - %@", identifier); templateCell.fd_isTemplateLayoutCell = YES; - templateCell.contentView.translatesAutoresizingMaskIntoConstraints = NO; +// templateCell.contentView.translatesAutoresizingMaskIntoConstraints = NO; templateCellsByIdentifiers[identifier] = templateCell; [self fd_debugLog:[NSString stringWithFormat:@"layout cell created - %@", identifier]]; }