iOSUITableView自动布局 ----动态cell
动态设置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;
}
1