I am trying to build a UICollectionView where the rows expand / collapse (for example, where the row only has a title initially, but when tapped expands to show a text view). I'm aware I can use UIContentConfiguration to swap a SwiftUI view for the cell's contentView, but I'm trying to do this in UIKit for configurability.
I have watched WWDC 22, 10068: What's new in UIKit, which made this sound easy...
I am using UICollectionLayoutListConfiguration for the UICollectionViewLayout.
When a cell is tapped, I update the subviews' constraints to the "expanded" state, but this just causes the subviews to expand beyond the cell height. All subviews are on cell.contentView. Calling layoutIfNeeded, invalidateIntrinsicContentSize, on cell doesn't change the cell height.
I assumed all I would need to do is set collectionView.selfSizingInvalidation = .enabledIncludingConstraints
, but is overriding intrinsicContentSize of the cell the only way to accomplish this?