iOS/Swift: Dynamically size UIStackView when one of its items gets larger

Viewed 53075

I have two items in a vertical UIStackView: a UILabel and a UITableView. When a dynamic amount of UITableViewCells 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?

4 Answers

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

Related