小demo
创建一个高度的 可变数组heightarray
并在 请求网络数据前 初始化
具体需要自己更改
//计算文本高度 !!!!!!!!!!!!!
CGSize size =[dic[@"网络请求下来的文本"] boundingRectWithSize:CGSizeMake(WIDTH-40, 1000) options:1 attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18]} context:nil].size;
[self.heightarray addObject:@(size.height)];
协议方法
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return [self.heightarray[indexPath.row] integerValue];
}