title: iOS Autolayout intrinsicContentSize = -1
body: <p>When using autolayout, calling intrinsicContentSize seems to be the method to determine what CGSize is required to properly fit the views content.</p>
  <p>However, this method is only supported for a limited number of existing UIViews.
  Anytime that I make a custom view, even if it is something as simple as a UILabel inside of a container UIView, that containing view is unable to determine its intrinsicContentSize (returns -1).</p>
  <p>I don't understand why the view is able to properly be displayed on the screen yet the view doesn't even know its own height...</p>
  <p>The UILabel in a container view is a simple example but I'm dealing with slightly more complicated UIViews where there are maybe 15 views nested within eachother. In order to determine the size of the view which contains all of its subviews, I have to manually create my own intrinsicContentSize method and do very time consuming work where I have to sum up all the heights of the subviews plus add to that all of the constraints.
  This process is terrible. It's very easy to miss out on a height somewhere by forgetting to add the height of one of the subviews or constraints. Also, the matter is further complicated by the fact that with dynamic subviews. For example, if the view has 2 columns of dynamic subviews, you need to manually find the height of the subviews+constraints for each column, compare these heights and return the larger of the two. Again, this is a simple example but often it's not so simple, causing many many migraines.</p>
  <p>Back to what I was asking earlier. How can iOS display the view yet not even know how tall the view is? There must be some way to find out what that height is. Thanks for reading.</p>
  <p>Here is an image to help visualize what I want.
  <a href="https://i.stack.imgur.com/uRA5K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uRA5K.png" alt="image" /></a></p>