问题
I'm using a UICollectionView
inside of a UITableViewCell
. It's all working fine, but i have some issues with Auto Layout. The UICollectionView
should just show the cells without horizontal or vertical scrolling.Because now I have a the scrollable UICollectionView
inside my UITableViewCell
the following code doesn't work for me to get the dynamic table cells' height for this cell, but for other cells.
self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.estimatedRowHeight = 44
I unchecked the option "scrolling enabled" in storyboard, but the result is, that i just can't scroll and don't see the rest of my collectionView.
Right now I simply set constraints from my UICollectionView
to the UITableViewCell
to all edges, but it's not working.
Would be great if someone have an idea.
Thanks a lot.
回答1:
You'll need to have a height constraint set on your UICollectionView
. If you've just pinned your UICollectionView
to your UITableViewCell
, it's getting its height from the table cell and the table cell is getting its height from the collection cell, so neither really knows what to do in that situation.
回答2:
I did meet a similar issue before. It turned out that I haven't fully set up the relationship between the UITableViewCell
and its containing elements so that they don't know how far to grow. I don't think this is related to embedded scrolling view. Just make sure that you have constraints set up between the UI elements inside the UITableViewCell
and the bottom of UITableViewCell
.
来源:https://stackoverflow.com/questions/32574881/uicollectionview-inside-of-uitableviewcell-autolayout