2019-12-12 OC cell自适应高度

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSDictionary * dic = _commentsArray[indexPath.row];
    NSString * comment = dic[@"content"];
    CGRect contentRect = [comment boundingRectWithSize:CGSizeMake(kWidth - 85, 9999) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]} context:nil];
    CGFloat heiht = 47;
    heiht += CGRectGetHeight(contentRect);
    if (heiht > 67) {
        return heiht;
    }
    return 67;
}

你可能感兴趣的:(2019-12-12 OC cell自适应高度)