- (CGFloat)getCellHeight:(UITableViewCell*)cell { [cell layoutIfNeeded]; [cell updateConstraintsIfNeeded]; CGFloat height = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height; return height; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { //只创建一个cell用作测量高度 static MyOrderCell *cell = nil; if (!cell){ cell = [tableView dequeueReusableCellWithIdentifier:@"MyOrderCellId"]; } OrderItemModel * item = [self.dataHelper getDataListBySection:indexPath.section][0]; [cell setCellInfo:item]; float heigh = [self getCellHeight:cell]; return heigh; }