title: IOS/Objective-C: Reusing Cell Throws off Autolayout of Different Size Elements in TableviewCell
body: <p>I am displaying feed items in a tableview.  Depending on the item, the cell must be larger or smaller--for example larger to accomodate a photo or larger still if it references another feed item such as an article and I have to display the item referenced.</p>
  
  <p>In most cases, I've used autolayout to get the cells to auto expand or contract based on the content.  However, in a couple cases, this was proving next to impossible so I reset the value of a constraint in code.  For example, if there is no photo in one case, I shrink the height of the cell in code as the cell was not shrinking on its own.</p>
  
  <p>This works fine when the page loads.  But when you scroll and reuse cells, it leads to weird effects such as the cell expanding vertically or lines being pushed into one another.</p>
  
  <p>Some questions on SO suggest using the method:</p>
  
  <pre><code>-(void) tableView:(UITableView *)tableView didEndDisplayingCell:(IDFeedCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
     //Undo changes here
  
      }
  </code></pre>
  
  <p>The problem is I don't know how to undo changes.  For example, if I made a cell smaller by setting</p>
  
  <pre><code>self.height.constant = 100;
  </code></pre>
  
  <p>Should I set it back to the constant value in storyboard?</p>
  
  <p>What value can I set it to when I don't know what the next item to resuse the cell will need in the way of dimensions.</p>
  
  <p>Thanks for any suggestions.  BTW, autolayout shows no issues.</p>