cell自适应大小(无控件)

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

NSDictionary *dic = self.sections[indexPath.row];

NSString *codename = dic[@"text"];

CGRect codenameRect = [codename boundingRectWithSize:CGSizeMake(

CGRectGetWidth(CGRectIntegral(tableView.bounds)) - 78,MAXFLOAT)

options:NSStringDrawingUsesLineFragmentOrigin

attributes:@{NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleBody]}context:nil];

return MAX(44.0f, CGRectGetHeight(CGRectIntegral(codenameRect)) + 50);

}

你可能感兴趣的:(cell自适应大小(无控件))