ios - UITableView contentSize 未更新

标签 ios swift uitableview uicollectionview

我有 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/

相关文章:

ios - 从滑动中排除一个单元格行以删除

ios - React Native 多个 panresponders

Objective-C 宏 - 调用单例对象的方法

ios - Swift模板库

ios - 如何在 SWIFT 3 中对 UITableView 执行动态创建部分和单元格

ios - 使用自动布局更改 UIPickerView 位置

ios - NSLog 与某些 NSURL 崩溃 - iOS 9.2

swift - 在应用重新启动时保留简单的文本文件

iphone - 删除行时崩溃 - 部分中的不一致未更新

ios - 自定义单元格标签不起作用