title: iOS AutoLayout multi-line UILabel
body: <p>Following question is sort-of continuation of this one:</p>
  
  <p><a href="https://stackoverflow.com/questions/12789013/ios-multi-line-uilabel-in-auto-layout">iOS: Multi-line UILabel in Auto Layout</a></p>
  
  <p>The main idea is that every view is supposed to state it's "preferred" (intrinsic) size so that AutoLayout can know how to display it properly. 
  UILabel is just an example of a situation where a view <strong>cannot</strong> by itself know what size it needs for display. It depends on what width is provided.</p>
  
  <p>As <strong>mwhuss</strong> pointed out, <em>setPreferredMaxLayoutWidth</em> did the trick of making the label span across multiple lines. But that is not the main question here. The question is where and when do I get this <em>width</em> value that I send as an argument to <em>setPreferredMaxLayoutWidth</em>.</p>
  
  <p>I managed to make something that looks legit, so correct me if I am wrong in any way and tell me please if you know a better way. </p>
  
  <p>In the UIView's</p>
  
  <pre><code>-(CGSize) intrinsicContentSize
  </code></pre>
  
  <p>I <em>setPreferredMaxLayoutWidth</em> for my UILabels according to self.frame.width.</p>
  
  <p>UIViewController's</p>
  
  <pre><code>-(void) viewDidLayoutSubviews
  </code></pre>
  
  <p>is the first callback method I know where subviews of the main view are appointed with their exact frames that they inhabit on the screen. From inside that method I, then, operate on my subviews, invalidating their intrinsic sizes so that UILabels are broken into multiple lines based on the width that was appointed to them.</p>