我的目标: 每个 UITableView 单元格包含 1 个 UIColletionViewController (动态项目计数)
问题: UITableView 'HeightForRow 的委托,在 UIColletionViewController 完成加载他的视图 + 高度之前调用。
结果: UITableView 'HeightForRow = 0
如何正确设置 UITableView“HeightForRow”委托? UIColletionViewController 的内容高度尚未加载
结果应该如下图所示:
已经尝试:
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.estimatedRowHeight = 300.0;
self.tableView.rowHeight = UITableViewAutomaticDimension;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
//not working well
return UITableViewAutomaticDimension;
//also tried this:
ResultsTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
Object * object = [_array objectAtIndex:indexPath.section];
[cell setCellObject:object]; //this is build the cell ui
return cell.collection.rect.size.height;
}