1.父tableview 的cell里面嵌套 子tableview,父级cell高度自适应撑起
1)子级cell高度固定,可以通过数组数量*cell的高度计算tableview的高度,撑起父级cell
在父级cell里面进行刷新高度,方法如下:
a.在赋值数组是刷新tableview
[self.tableView reloadData];
[self.contentView layoutIfNeeded];
[self layoutIfNeeded];
b.
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
NSInteger index = 1;
index = self.model.goods.count;
CGFloat height = (100 + 16) * index;
self.tableViewHeightCons.constant = height;
return index;
}
2)子级cell高度自适应时
通过一下方法获取子tableview的高度
pragma mark reload 完tableview,获取tableview的contentSize
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath )indexPath {
if([indexPath row] == ((NSIndexPath)[[tableView indexPathsForVisibleRows] lastObject]).row){
dispatch_async(dispatch_get_main_queue(),^{
self.tableViewHeightCons.constant = tableView.contentSize.height;
});
}
} 
3.collectionView高度自适应方法:
[self.CollectionView reloadData];
// 延迟一秒去执行  成功回调
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.CollectionViewHeightCons.constant = self.infoCollectionView.collectionViewLayout.collectionViewContentSize.height;
});