【发布时间】:2018-10-05 14:27:42
【问题描述】:
我有 UITableView 和 UITableViewCell,其中包含 UICollectionView,如:
- UITableViewCell
- UITableViewCell
- UICollectionViewCell
- UICollectionViewCell
在 UICollectionView 中数据是动态添加的。 我已经订阅了 UICollectionView contentSize,并且我正在根据 contentSize 更改 UICollectionView 的框架。它工作正常,包含 UICollectionView 的 UITableViewCell 框架正在正确更改,但 UITableView contentSize 没有更新。我不明白为什么?
UITableView 项目高度设置为 UITableViewAutomaticDimension
【问题讨论】:
-
请提供一些代码作为示例:-)
-
我什至不知道提供给什么.. ``` collectionView.rx.contentSize .subscribe(onNext: { [collectionView] contentSize in guard let collectionView = collectionView else { return } collectionView.frame = CGRect(origin: collectionView.frame.origin, size: contentSize) }).disposed(by: bag) ``
-
我已经订阅了 UICollectionView contentSize,我正在根据 contentSize 更改 UICollectionView 的框架这样做的原因是什么?
-
@arturdev 为了让 UITableView 自动重新计算自己的 contentSize,以及当我们拥有带有单个 UILabel(顶部、底部、前导、尾随约束)的 UITableViewCell 以及 UILabel 扩展时,UITableViewCell 和 contentSize 相应地扩展
-
@Gikas 能否提供所需结果的屏幕截图?
标签: ios swift uitableview uicollectionview