title: Why does presenting a modal UIViewController cause setNeedsLayout on the presenting controller?
body: <p>It appears that presenting and dismissing a view controller both prompt the <strong>presenting</strong> view to layout its subviews and/or update its constraints. With a heavy view hierarchy, this is introducing performance issues. Again - this is the existing, currently displayed view. The modal being created and displayed is very light.</p>
  
  <p>This occurs whether I use autolayout (as in my example project) or not.</p>
  
  <p>I have built a <a href="https://github.com/benpackard/ChildAutolayoutTest" rel="nofollow">demo project</a> that approximates an app I am working on. There is a main parent controller with a horizontally scrolling <code>UIScrollView</code>. Multiple child controllers are added to the parent controller, and their views are added to the scrollview and arranged using <code>NSLayoutConstraint</code>s. Each child view has one subview itself, a simple <code>UIView</code>, also arranged with a constraint. </p>
  
  <p>In the navigation bar, there is a button to launch a modal. When presented, the parent controller makes a call to <code>setNeedsLayout</code> on each child view, multiple times. In my demo project, I am overriding <code>setNeedsLayout</code> to log when it is accessed. The same occurs when closing the modal. Open and close the modal a few times and observe the console.</p>
  
  <p>I can see no reason why a new layout is needed, and with more complex views I am finding that hundreds of these calls are firing, with a noticeable performance impact.</p>
  
  <p>Note that when the layout code from <code>ChildView</code> is omitted, <code>setNeedsLayout</code> is not called. I encourage you to comment out the constraints and see the difference in the logging.</p>
  
  <p>Why is this happening? How can I prevent an unnecessary layout pass when presenting and dismissing a modal?</p>