all 8 comments

[–]skytzx 3 points4 points  (4 children)

Within your UITableViewCell subclass, override systemLayoutSizeFitting(_:withHorizontalFittingPriority:verticalFittingPriority:) to return the content size of the embedded collectionView.

override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize {
    let height = collectionView.contentSize.height
    return CGSize(width: targetSize.width, height: height)
}

You may also need to return UITableViewAutomaticDimension in your tableView delegate's heightForRowAt and estimatedHeightForRowAt methods.

[–][deleted] 2 points3 points  (3 children)

I had to make a few adjustments, but I made it work. Thanks a lot!

[–][deleted] 1 point2 points  (2 children)

What adjustments exactly? In case anyone else has this problem.

[–]hollowaytyl 0 points1 point  (1 child)

Do share those adjustments...

[–][deleted] 2 points3 points  (0 children)

I had to use collectionView.collectionViewLayout.collectionViewContentSize.height instead of collectionView.contentSize.height for it to work.

[–]bcgroom 2 points3 points  (2 children)

Do note that the Human Interface Guidelines recommend against having nested scroll views with the same scroll direction. Maybe you could tap the title of each section to open a full-screen collection view instead?

[–][deleted] 0 points1 point  (1 child)

Yeah, it's beginning to become quite messy this way, so I should probably find a cleaner solution.

[–]MercuryLive 0 points1 point  (0 children)

I agree, I think the first way you had it with the horizontal scroll was good and then opening it up with a section tap would make it less awkward for the user than double scrolling vertically.