title: Basic Understanding of Autolayout
body: <p>I've watched all relevant Autolayout WWDC Videos from 2012/13/14, and CS193P, and tutorials from a few other trusted sources. Using that knowledge and some trial and error, I've been able to use Autolayout to create some fairly complex screens, but occasionally I hit a stumbling block which shows me that my understanding of Autolayout is not complete. So I've recreated the simplest scenario I could think of to showcase one question that would be extremely useful to have answered:</p>
  
  <p><img src="https://i.stack.imgur.com/BZJ4J.png" alt="Simple Autolayout Error"></p>
  
  <p>In this situation, we've got two views:</p>
  
  <ul>
  <li>Left view is pinned to the top, bottom, and left of the screen</li>
  <li>Right view is pinned to the top, bottom, and right of the screen</li>
  <li>There is a Horizontal Spacing constraint between the two views</li>
  </ul>
  
  <p>The vertical positioning is determined by the top and bottom constraints with no errors, but the views both report "Missing Constraints" as they "Need constraints for: X position or width."</p>
  
  <p>I thought that the left view's X position is determined by being pinned to the left, and its width would grow/shrink as wide as it needs to be to still have a space between itself and the right view which is pinned to the right.</p>
  
  <p>I can see how it would be an issue for Autolayout to know <strong>which</strong> of the views would be the one to grow to meet the other - but I thought that was resolved by giving one view a higher Horizontal Compression Resistance Priority (or Horizontal Hugging). The view that is more resistant to being compressed or has a higher hugging value would stay the same width that it had in the Canvas and the other view would change its width to satisfy the constraints. Changing these priority values is not affecting the missing constraints errors. </p>
  
  <p>As can be seen in the screenshot, in the "Misplaced Views" section on the left, there is one view that has an expected width of more than double its canvas value, and one view that has an expected width of 0. This matches up with the error that we need constraints for width, but why?</p>
  
  <p>I believe understanding why this is could be helpful in understanding more complex Autolayout relationships. Thanks in advance!</p>