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
原文地址:https://www.cnblogs.com/fantasy3588/p/5248960.html