Raoul
Raoul

Reputation: 153

Self-sizing UITableView embedded in UICollectionViewCell

For an iOS application I'm working on the following layout: enter image description here

I'm trying to achieve this by embedding a tableview inside a collection view cell. The height of the individual collectionView cells is dynamic (by setting the layouts' estimatedItemSize and using auto layout for the cells). The problem which I encountered is that I can't get the embedded tableView to size dynamically according to the given data.

Is there any way I can update the size of the tableView in the cell dynamically

Upvotes: 0

Views: 304

Answers (1)

Jignesh Patel
Jignesh Patel

Reputation: 146

For collection view or table view, auto-sizing will only work if you have provided enough constraint to calculate it's CGRect. In your case, you have table view inside collection view and table view's height can be anything as it can scroll the content.

Try to give table view height constraint then change constraint's value to table view's contentsize.height, Then it might work.

Maybe consider using UIStackView.

Upvotes: 1

Related Questions