Skip to content

Commit 1aec0c4

Browse files
committed
fix #20: remove any fixed dimension constraint when using automatic sizing in row's contentView
1 parent 90b2db4 commit 1aec0c4

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

Sources/ScrollStackController/ScrollStackRow.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,22 @@ open class ScrollStackRow: UIView, UIGestureRecognizerDelegate {
352352
}
353353
}
354354

355+
private func removeFixedDimensionConstraintsIfNeeded(_ contentView: UIView) {
356+
let fixedDimensions = contentView.constraints.filter({
357+
$0.firstAttribute == .height || $0.firstAttribute == .width
358+
})
359+
contentView.removeConstraints(fixedDimensions)
360+
}
361+
355362
private func setupRowSizeToFitLayout() {
356363
guard let stackView = stackView, let contentView = contentView else { return }
357-
364+
365+
// If user changed the way of how the controller's view is resized
366+
// (ie from fixed height to auto-dimension) we should need to remove
367+
// attached constraints about height/width in order to leave the viww to
368+
// auto resize according to its content.
369+
removeFixedDimensionConstraintsIfNeeded(contentView)
370+
358371
var bestSize: CGSize!
359372
if stackView.axis == .vertical {
360373
let maxAllowedSize = CGSize(width: stackView.bounds.size.width, height: CGFloat.greatestFiniteMagnitude)

0 commit comments

Comments
 (0)