为什么CollectionView单元内部其他collectionView的大小错误?

问题描述

我在collectionViewCell内部有一个collectionView(嵌套)。当我打开此VC时,嵌套collectionView内的单元格大小错误。上下滚动后-一切都很好。 我想在滚动方法layoutSubviews时正在调用。 但是当我添加 cell.setNeedsLayout() cell.layoutIfNeeded()func collectionView(_ collectionView: UICollectionView,cellForItemAt indexPath: IndexPath)内部,结果保持不变。

enter image description here

enter image description here

约束:

enter image description here

解决方法

我认为问题不在于尺寸,而在于约束。

请分享您的代码段