Hiding a UILabel from a UITableViewCell doesn't resize the contentView
<p>I'm trying to create a dynamic <code>UITableView</code> where a <code>cell</code> can expand/collapse as the user selects the <code>cell</code>.</p>

<pre><code>- (void)setUpCell:(DynamicTableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
    cell.label.text = [self.dataSource objectAtIndex:indexPath.row];
    cell.secondLabel.text = [self.dataSource objectAtIndex:self.dataSource.count - indexPath.row - 1];
    if ([self.isVisible[indexPath.row] isEqual:@NO]) {
        cell.secondLabel.hidden = YES;
    } else {
        cell.secondLabel.hidden = NO;
    }
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    DynamicTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    [self setUpCell:cell atIndexPath:indexPath];

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    DynamicTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if ([self.isVisible[indexPath.row] isEqual: @YES]) {
        self.isVisible[indexPath.row] = @NO;
        cell.secondLabel.hidden = YES;
    } else {
        self.isVisible[indexPath.row] = @YES;
        cell.secondLabel.hidden = NO;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    static DynamicTableViewCell *cell = nil;
    static dispatch_once_t onceToken;

    dispatch_once(&amp;onceToken, ^{
        cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    });

    [self setUpCell:cell atIndexPath:indexPath];

    return [self calculateHeightForConfiguredSizingCell:cell];
}

- (CGFloat)calculateHeightForConfiguredSizingCell:(DynamicTableViewCell *)sizingCell {
    [sizingCell layoutIfNeeded];

    CGSize size = [sizingCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
    return size.height;
}
</code></pre>

<p>I forked <a href="https://github.com/tjosten/iOS-UITableViewCell-with-dynamic-height" rel="nofollow" title="this">this</a> project and have the test code <a href="https://github.com/pwiebe/iOS-UITableViewCell-with-dynamic-height" rel="nofollow" title="here">here</a>.</p>

<p>Once the cell has been sized it does not change when selecting the cell, only hides/shows the content of the cell.  I've tried replacing the explicit size calculation with <code>UITableViewAutomaticDimension</code>.  Also tried reloading the cell.  Seems once the cell size has been calculated, it does not change.</p>

<p>Any suggestions as to what to try would be greatly appreciated! </p>