title: UITableview with Autolayout and NSFetchedResults controller cell layout bug on insert
body: <p>I seem to be having a very strange problem with my UITableview cells and autolayout. So my tableview is set up as follows:</p>
  
  <ul>
  <li>I have a UITableView within a UIViewController that I created via Interface builder using Autolayout</li>
  <li>My tableview is using UITableViewAutomaticDimension so that the cells can resize based on the text within them.</li>
  <li>Each cell has 2 subviews within it. A front view and a back view. The back view contains the buttons for my slide-able cells</li>
  <li>I am using NSFetchedResults controller to update the tableview</li>
  </ul>
  
  <p>The problem occurs when I tap on a cell and am taken to the next view. Then I create a core data item within that view and save so that it is inserted into my tableview (now behind the current view controller).</p>
  
  <p>What happens is that the newly inserted cell seems to lose all autolayout constraints and all view elements are on top of each other in the top left of the cell. It also looks like they are not even contained within the front view for the cell (or the front view has a width and height of 0).</p>
  
  <p>Example:</p>
  
  <p><a href="https://i.stack.imgur.com/5jCEK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5jCEK.png" alt="Example"></a></p>
  
  <p>It gets even stranger. If I refresh the tableview by pulling down and the cells are reloaded it corrects itself. However, if I refresh the tableview again then the problem appears again but on a different cell. This bug does not happen consistantly which is rather frustrating.</p>
  
  <p>Any help would be appreciated as I only have a few remaining hairs on my head to pull out at this stage.</p>
  
  <p>Thanks in advance!</p>