【发布时间】:2016-10-20 02:06:03
【问题描述】:
我有 tableview(A) 的每个自定义单元格都有 tableview(B) 和动态表格视图单元格。
在 tableview(A) cellForRowAtIndex。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
MainMessageTVCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MsgMainCell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
NSInteger index = indexPath.row;
MessageMain *result = tableData[index];
cell.dateLabelTC.text = [NSString stringWithFormat:@"Date : %@",result.createdTime];
cell.subjectLabelTC.text = [NSString stringWithFormat:@"Subject : %@",result.subject];
NSArray *arrList = result.messageList;
[cell setupTableData:(NSMutableArray *)arrList];
[cell setNeedsUpdateConstraints];
}
在 tableview(A) 的自定义单元格处重新加载 tableview(B)。
-(void)setupTableData:(NSMutableArray *)tableData{
_tableData = tableData;
[self.tableView reloadData];
}
-(void)updateConstraints{
[super updateConstraints];
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView layoutIfNeeded];
CGFloat height = self.tableView.contentSize.height;//+1000;
tableBHeightConstraints.constant = height;
});
}
tableBHeightConstraints 是 tableview(A) 的子单元格中 table view(B) 的高度约束。 tableBHeightConstraints.constant 没有得到所有计算约束的正确值。
在动态表格单元格的高度设置之后准确获取 tableView.contentSize.height 的最佳位置或方法是什么。
这是tableview(B)的单元格
请帮助大家。
【问题讨论】:
标签: ios objective-c iphone autolayout nested-table