UICollectionView inside of UITableViewCell - AutoL

2019-05-20 04:36发布

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.

2条回答
Bombasti
2楼-- · 2019-05-20 04:54

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.

查看更多
Juvenile、少年°
3楼-- · 2019-05-20 05:08

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.

查看更多
登录 后发表回答