简体   繁体   English

UITableView contentSize未更新

[英]UITableView contentSize does not updated

I have the UITableView with UITableViewCell, which contains UICollectionView, as: 我有带有UITableViewCell的UITableView,其中包含UICollectionView,如下所示:

  • UITableViewCell 的UITableViewCell
  • UITableViewCell 的UITableViewCell
    • UICollectionViewCell UICollectionViewCell
    • UICollectionViewCell UICollectionViewCell

In UICollectionView data is adding dynamically. 在UICollectionView中,数据是动态添加的。 I have subscribed to UICollectionView contentSize and I am changing frame of UICollectionView accordingly to contentSize. 我已经订阅了UICollectionView contentSize,并且正在将UICollectionView的框架相应地更改为contentSize。 It's working fine and frame of UITableViewCell containing UICollectionView is changing correctly, but UITableView contentSize does not updating. 它工作正常,并且包含UICollectionView的UITableViewCell的框架正确更改,但是UITableView contentSize不会更新。 And I don't understand why? 我不明白为什么?

UITableView items height is set to UITableViewAutomaticDimension UITableView项的高度设置为UITableViewAutomaticDimension

The best solution I've found. 我找到的最好的解决方案。 This is to do the calculation of height manually, without using UITableViewAutomaticDimension. 这是手动执行的高度计算,而不使用UITableViewAutomaticDimension。

Yes, you have to spend a time for writing this. 是的,您必须花一些时间来编写此代码。

After each added element of the UICollectionViewCell, you need to make an update your tableView (depending on what suits you): 在UICollectionViewCell的每个添加的元素之后,您需要更新tableView(取决于适合您的对象):

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

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