I am using a UICompositionalLayout to set the layout of my collection view. For the header of each section I am using a UICollectionReusableView, which contains three buttons at the top and two textviews below them. The UI is set up in the following way
The user should be able to write some notes in both uitextviews and those views should resize their height according to their intrinsic heights, I have disabled scrolling for both textfields but whenever the user writes more than the width of the collection view, that part of the text disappears instead of the textview to resize.
The following is the code I am using for the collection view compositional layout
static func setupCollectionViewCompositionalLayout() -> UICollectionViewCompositionalLayout{
let compositionalLayout = UICollectionViewCompositionalLayout { (sectionNumber, env) -> NSCollectionLayoutSection? in
let item = NSCollectionLayoutItem(layoutSize: .init(widthDimension: .fractionalWidth(1.0), heightDimension: .fractionalHeight(1.0)))
item.contentInsets.trailing = 16
item.contentInsets.leading = 16
let group = NSCollectionLayoutGroup.vertical(layoutSize: .init(widthDimension: .fractionalWidth(1.0), heightDimension: .fractionalHeight(1.0)), subitems: [item])
let section = NSCollectionLayoutSection(group: group)
let headerSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(200))
let header = NSCollectionLayoutBoundarySupplementaryItem(layoutSize: headerSize, elementKind: TestTableCollectonViewTopHeaderCollectionReusableView.reuseIdentifier, alignment: .top)
section.boundarySupplementaryItems = [header]
return section
}
return compositionalLayout
}
The reusable view comes from a xib with very simple auto layout constraints, the buttons have fixed width and heights, all subviews have 8 points from leading and trailing and there is a spacing of 16 between subviews.
According to this constraints the layout should resize according to the content but the text keeps disappearing and the header doesn't resize as it should be, even though I'm setting the height to be calculated according to the auto layout of the view.
If someone could point me in the right way, it would be really appreciated
Thanks in advance