title: Auto-resizing Cell not updating height on first load
body: <p>I have a custom tableViewCell:</p>
  
  <p><a href="https://i.stack.imgur.com/zBSFQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zBSFQ.png" alt="enter image description here"></a></p>
  
  <p>The <code>Extra text</code> label sometimes is hidden so the cell should autoresize.</p>
  
  <p>This <code>Extra text</code> label is hidden setting the .active = NO; for the rules around the label:</p>
  
  <pre><code>-(void)setShowExtraText:(BOOL)showExtraText
  {
      _showExtraText = showExtraText;
      if (showExtraText) {
  
          self.textfieldBottomSuperviewConstraint.active = NO;
  
          self.extraText.hidden = NO;
  
          self.textfieldExtraTextConstraint.active = YES;
          self.leadingExtraTextConstraint.active = YES;
          self.extraTextBottomContraint.active = YES;
      }
      else{
          self.extraText.hidden = YES;
  
          self.textfieldExtraTextConstraint.active = NO;
          self.leadingExtraTextConstraint.active = NO;
          self.textfieldBottomSuperviewConstraint.active = YES;
          self.extraTextBottomContraint.active = NO;
      }
  }
  </code></pre>
  
  <p>There is only one cell with has the <code>Extra text</code> label no hidden, and this is the last one in the tableView. </p>
  
  <p>The problem is when the tableView loads the heigh of the cells are wrong. Also taking a look the <code>Debug View Hierarchy</code> it shows is ignoring the code to desactivate the rules. Because the rules desactivated are still in the view.</p>
  
  <p>If I do scroll down and scroll up the layout of the cells are right, showing the the one with the Extra text and the ones without the extra text correctly.</p>
  
  <p>I tried adding:</p>
  
  <pre><code>    [self setNeedsLayout];
      [self layoutIfNeeded];
  </code></pre>
  
  <p>I tried to using SizeClasses. ( I wasn't using sizeClasses before )</p>
  
  <p>I run out of ideas, any idea?</p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p>Update 1</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  
          UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellWithExtraText" forIndexPath:indexPath];
  
          [cell setShowExtraText:(indexPath.section == LOGIN_SECTION &amp;&amp; indexPath.row == REPEAT_PASSWORD_ROW)];
  
          return cell;
  }
  </code></pre>
  
  <hr>
  
  <p>Update 2</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  
          UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellWithExtraText" forIndexPath:indexPath];
  
          [cell setShowExtraText:(indexPath.section == LOGIN_SECTION &amp;&amp; indexPath.row == REPEAT_PASSWORD_ROW)];
  
          [cell updateConstraintsIfNeeded];
  
          [self.tableView beginUpdates];
          [self.tableView endUpdates];
  
          [self.tableView setNeedsLayout];
          [self.tableView layoutIfNeeded];    
  
          return cell;
  }
  </code></pre>