title: Resize UIView inside UIScrollView with AutoLayout for scrolling?
body: <p>I have a layout as follows(Using AutoLayout,iPad):</p>
  
  <p><img src="https://i.stack.imgur.com/iVU8z.png" alt="Xcode screenshot"></p>
  
  <p>The <code>UIScrollView</code> has Top,Bottom,Leading,Trailing space to the superview as 0. The <code>UIView</code> also has all four similar constraints. The second <code>UILabel</code> has its height set to 0 programmatically (since more than a screenful of text is shown here). Also, these four pin constraints have also been set up from the <code>UIView</code> to <code>UIScrollView</code>.</p>
  
  <p>When the XIB is loaded, this <code>UILabel</code> shows long lines of text correctly. But scrolling does not work. This is a screenshot of the running app on an iPad: </p>
  
  <p><img src="https://i.stack.imgur.com/UDyAn.png" alt="enter image description here"></p>
  
  <p>The yellow background is set for the outermost view and the grey one for the <code>UIView</code>. If you see carefully at the end of the screenshot, the <code>UILabel</code>'s text seems to overflow past the <code>UIView</code>.</p>
  
  <p>I suspect that because the <code>UIView</code> cannot "capture" the size of it's subviews, the <code>UIScrollView</code> cannot calculate it's contentsize too(there's no reason for the scrollbar to work if its content view is only equal to one screen). Why is this happening even when the <code>UILabel</code> is clearly a subview of the <code>UIView</code>? If my suspicions are right, <strong>how do I set the <code>UIView</code>'s height equal to the actual content size so that my <code>UILabel</code> is properly "contained" in it?</strong></p>
  
  <p>(Setting the <code>UIView</code>'s height,width statically is not an option) .</p>
  
  <p>NB: Tested the XIB without the <code>UIView</code> and only a single <code>UILabel</code> (with long text) inside a <code>UIScrollView</code>. Now scrolling works(since, I presume, the scroll view can calculate its content size).</p>
  
  <p>NB2: I also tried the answers in <a href="https://stackoverflow.com/questions/3605393/iphone-uiview-resize-frame-to-fit-subviews">this SO question</a> and <a href="http://spin.atomicobject.com/2014/03/05/uiscrollview-autolayout-ios/" rel="nofollow noreferrer">this post</a> but my <code>UIView</code> simply wont extend beyond the dimensions of the screen. (I only care about horizontal scrolling)</p>