From 4bc29116f37de4f8a998d199e5d2fb14bf9c2b6b Mon Sep 17 00:00:00 2001 From: Ge Date: Fri, 28 Sep 2018 11:29:03 +0800 Subject: [PATCH 1/2] fix crash on ios10.2 fix crash on ios10.2 --- Classes/UITableView+FDTemplateLayoutCell.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Classes/UITableView+FDTemplateLayoutCell.m b/Classes/UITableView+FDTemplateLayoutCell.m index f21752b..294d2a4 100644 --- a/Classes/UITableView+FDTemplateLayoutCell.m +++ b/Classes/UITableView+FDTemplateLayoutCell.m @@ -82,10 +82,17 @@ - (CGFloat)fd_systemFittingHeightForConfiguratedCell:(UITableViewCell *)cell { [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]]; } From 9765d86f872541f5e236e425f3b9a8ae1bc8f70d Mon Sep 17 00:00:00 2001 From: Ge Date: Fri, 28 Sep 2018 13:47:59 +0800 Subject: [PATCH 2/2] fix bug --- Classes/UITableView+FDTemplateLayoutCell.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/UITableView+FDTemplateLayoutCell.m b/Classes/UITableView+FDTemplateLayoutCell.m index 294d2a4..fbdfdfd 100644 --- a/Classes/UITableView+FDTemplateLayoutCell.m +++ b/Classes/UITableView+FDTemplateLayoutCell.m @@ -79,7 +79,7 @@ - (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;