简体   繁体   English

为什么 CollectionView cell insider 其他 collectionView 的大小错误?

[英]Why CollectionView cell insider other collectionView has wrong size?

I have a collectionView (nested) inside a collectionViewCell.我在 collectionViewCell 中有一个 collectionView(嵌套)。 When I open this VC, the cell inside nested collectionView have wrong size.当我打开这个 VC 时,嵌套 collectionView 中的单元格大小错误。 After scroll down and up - everything is fine.向下和向上滚动后 - 一切都很好。 I think when I am scrolling method layoutSubviews are calling.我想当我滚动时调用layoutSubviews方法。 But when I added cell.setNeedsLayout() cell.layoutIfNeeded() inside func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) the result is not change.但是当我在func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath)中添加cell.setNeedsLayout() cell.layoutIfNeeded()时,结果没有改变。
在此处输入图像描述

在此处输入图像描述

Constraints:约束: 在此处输入图像描述

i think problem is not with the size, it is from constraints.我认为问题不在于尺寸,而在于限制。

Would you please share a snippet of your code你能分享你的代码片段吗

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM