@@ -245,9 +245,10 @@ open class ScrollStackRow: UIView, UIGestureRecognizerDelegate {
245245 setNeedsUpdateConstraints ( )
246246 }
247247
248- open override func updateConstraints( ) {
248+ open override func layoutSubviews( ) {
249+ super. layoutSubviews ( )
250+ // called the event to update the height of the row.
249251 askForCutomizedSizeOfContentView ( animated: false )
250- super. updateConstraints ( )
251252 }
252253
253254 private func applyParentStackAttributes( ) {
@@ -366,16 +367,25 @@ open class ScrollStackRow: UIView, UIGestureRecognizerDelegate {
366367
367368 var bestSize : CGSize !
368369 if stackView. axis == . vertical {
369- let maxAllowedSize = CGSize ( width: stackView. bounds. size. width, height: CGFloat . greatestFiniteMagnitude)
370- bestSize = contentView. systemLayoutSizeFitting ( maxAllowedSize, withHorizontalFittingPriority: . required, verticalFittingPriority: . defaultLow)
370+ let maxAllowedSize = CGSize ( width: stackView. bounds. size. width, height: 0 )
371+ bestSize = contentView. systemLayoutSizeFitting (
372+ maxAllowedSize,
373+ withHorizontalFittingPriority: . required,
374+ verticalFittingPriority: . fittingSizeLevel
375+ )
371376 } else {
372- let maxAllowedSize = CGSize ( width: CGFloat . greatestFiniteMagnitude, height: stackView. bounds. size. height)
373- bestSize = contentView. systemLayoutSizeFitting ( maxAllowedSize, withHorizontalFittingPriority: . defaultLow, verticalFittingPriority: . required)
377+ let maxAllowedSize = CGSize ( width: 0 , height: stackView. bounds. size. height)
378+ bestSize = contentView. systemLayoutSizeFitting (
379+ maxAllowedSize,
380+ withHorizontalFittingPriority: . fittingSizeLevel,
381+ verticalFittingPriority: . required
382+ )
374383 }
375384
376385 setupRowToFixedValue ( bestSize. height)
377386 }
378387
388+
379389 // MARK: - Handle Touch
380390
381391 public func gestureRecognizer( _ gestureRecognizer: UIGestureRecognizer , shouldReceive touch: UITouch ) -> Bool {
0 commit comments