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,21 +96,12 @@ - (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-
100- /* 修复1.3版本存在的一个bug:给contentView添加宽度为0的约束,会与已有子视图约束冲突. */
101- if (0 != contentViewWidth) {
102- NSLayoutConstraint *tempWidthConstraint =
103- [NSLayoutConstraint constraintWithItem: cell.contentView
104- attribute: NSLayoutAttributeWidth
105- relatedBy: NSLayoutRelationEqual
106- toItem: nil
107- attribute: NSLayoutAttributeNotAnAttribute
108- multiplier: 1.0
109- constant: contentViewWidth];
110- [cell.contentView addConstraint: tempWidthConstraint];
99+ if (contentViewWidth > 0 ) {
100+ NSLayoutConstraint *widthFenceConstraint = [NSLayoutConstraint constraintWithItem: cell.contentView attribute: NSLayoutAttributeWidth relatedBy: NSLayoutRelationEqual toItem: nil attribute: NSLayoutAttributeNotAnAttribute multiplier: 1.0 constant: contentViewWidth];
101+ [cell.contentView addConstraint: widthFenceConstraint];
111102 // Auto layout engine does its math
112103 fittingSize = [cell.contentView systemLayoutSizeFittingSize: UILayoutFittingCompressedSize];
113- [cell.contentView removeConstraint: tempWidthConstraint ];
104+ [cell.contentView removeConstraint: widthFenceConstraint ];
114105 }
115106 }
116107
You can’t perform that action at this time.
0 commit comments