我有 UITableView 和 UITableViewCell,其中包含 UICollectionView,如下:
- UITableViewCell
- UITableViewCell
- UICollectionViewCell
- UICollectionViewCell
在 UICollectionView 中,数据是动态添加的。 我已经订阅了 UICollectionView contentSize,并且我正在根据 contentSize 更改 UICollectionView 的框架。它工作正常,包含 UICollectionView 的 UITableViewCell 框架正在正确更改,但 UITableView contentSize 不会更新。我不明白为什么?
UITableView 项目高度设置为 UITableViewAutomaticDimension
最佳答案
我找到的最好的解决方案。这是手动计算高度,而不使用 UITableViewAutomaticDimension。
是的,你必须花时间写这个。
在 UICollectionViewCell 的每个添加元素之后,您需要更新您的 tableView (取决于适合您的内容):
关于ios - UITableView contentSize 未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52667832/