动态设置cell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (_testCell == nil) {
_testCell = [TestCell cellFromNib];
}
_testCell.name.text = arr[indexPath.row];
_testCell.name.preferredMaxLayoutWidth = tableView.bounds.size.width - 10;
CGFloat cellHeight = [_testCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
return cellHeight + 1;
}
原文:http://www.cnblogs.com/fantasy3588/p/5248960.html