I have two items in a vertical UIStackView
: a UILabel
and a UITableView
. When a dynamic amount of UITableViewCell
s get added to the UITableView
at runtime, the UIStackView
does not get larger.
Is there a general way to increase the size of the UIStackView
?
You should call sizeToFit()
and layoutIfNeeded()
on the subviews of the stackView. Constrain the UIStackView as you normally would, and constrain the subviews as you normally would.
Also, you need to have it set to Fill Proportionally and it will resize to fit the new content.
Make sure you don't have a bottom constraint of a height constraint on the stackview. You should only need left, right and top constraint.
I had this on iOS 12, while it was working fine on iOS 13. Just set:
stackView.distribution = .fillProportionally
Fixed it :)
you one need to fill proportionally and it will work according to your code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With