File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,11 +96,13 @@ - (CGFloat)fd_heightForCellWithIdentifier:(NSString *)identifier configuration:(
9696 } else {
9797 // Add a hard width constraint to make dynamic content views (like labels) expand vertically instead
9898 // of growing horizontally, in a flow-layout manner.
99- NSLayoutConstraint *tempWidthConstraint = [NSLayoutConstraint constraintWithItem: templateLayoutCell.contentView attribute: NSLayoutAttributeWidth relatedBy: NSLayoutRelationEqual toItem: nil attribute: NSLayoutAttributeNotAnAttribute multiplier: 1.0 constant: contentViewWidth];
100- [templateLayoutCell.contentView addConstraint: tempWidthConstraint];
101- // Auto layout engine does its math
102- fittingSize = [templateLayoutCell.contentView systemLayoutSizeFittingSize: UILayoutFittingCompressedSize];
103- [templateLayoutCell.contentView removeConstraint: tempWidthConstraint];
99+ if (contentViewWidth > 0 ) {
100+ NSLayoutConstraint *widthFenceConstraint = [NSLayoutConstraint constraintWithItem: templateLayoutCell.contentView attribute: NSLayoutAttributeWidth relatedBy: NSLayoutRelationEqual toItem: nil attribute: NSLayoutAttributeNotAnAttribute multiplier: 1.0 constant: contentViewWidth];
101+ [templateLayoutCell.contentView addConstraint: widthFenceConstraint];
102+ // Auto layout engine does its math
103+ fittingSize = [templateLayoutCell.contentView systemLayoutSizeFittingSize: UILayoutFittingCompressedSize];
104+ [templateLayoutCell.contentView removeConstraint: widthFenceConstraint];
105+ }
104106 }
105107
106108 // Add separator's height, using a private property in UITableViewCell.
You can’t perform that action at this time.
0 commit comments