//声明tableview
@property(nonatomic,strong)UITableView * tableView;
//自定义的cell
@property(nonatomic,strong)TopicDetailsTableViewCell * cell;
//把高度传过去(这个写在自定义cell的.h里,吧相对高度传过去)
@property(nonatomic,assign)CGFloat maxCellY;
自定义cell的.m里
self.maxCellY = CGRectGetMaxY(labelAnswerContent.frame)+12;
//高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return _cell.maxCellY;
}
//cel定制方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString * string=@"strtopic";
_cell = [tableView dequeueReusableCellWithIdentifier:string];
if (_cell==nil) {
_cell=[[TopicDetailsTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:string];
}
AnswerModer * model = self.dataSouce[indexPath.row];
_cell.model = model;
return _cell;
}