title: UIStackView and Multiline Labels?
body: <p>I've tried to get this to work but interface builder is doing my head in and I was wondering if anyone has a proper solution for this.</p>
  
  <p>So I want to have a stackview that contains a label with multiple lines inside. The first hit on google (<a href="https://stackoverflow.com/questions/34386528/multiline-label-in-uistackview" title="read here">read here</a>) tells you to embed the label within a view (A), then drag that view into another view (B) (because the embedded view (A) has a 20pixel pad) and then unembed the first view (A).... voila. Except this only tricks the stackview for horizontal stacks and if you continue to stack the view you will still have a ton of problems (I will demonstrate with screenshots later in the question).</p>
  
  <p>I found <a href="https://medium.com/@jkoch/stacking-vs-multilines-in-xcode-7-2e26d2056cde" rel="nofollow noreferrer" title="another guide">another guide</a> on google that criticizes a potential fix for the problem, fixing the stackviews width. The author makes the point that Apple didn't intend for you to be doing that, after all it's supposed to be auto layout, not fixed layout. This guide theorises that the issue is just a bug and that you can create a stackview with a single line label, set it all up and THEN add the multiple lines. I tried this and it didn't work, it simply messed the entire stack view up! The stack view will warp and essentially break unless the label has number of lines set to 1 and only 1. <a href="https://i.stack.imgur.com/2oal4.png" rel="nofollow noreferrer">(Image 1) Stackview with label set to have multiple lines.</a></p>
  
  <p>So I talked earlier about embedding the paragraph label within a view. <a href="https://i.stack.imgur.com/jgkQZ.png" rel="nofollow noreferrer">This doesn't cause any errors in the storyboard,(Image 2)</a> you can't really align the text properly with the other UIStacks but that's not an immediate problem for me to solve. What IS a problem is what happens at runtime....
   <a href="https://i.stack.imgur.com/NLfYo.png" rel="nofollow noreferrer">Simulator, Portrait (Image 3)</a>, <a href="https://i.stack.imgur.com/myTwX.png" rel="nofollow noreferrer">Simulator, Landscape (Image 4)</a>. </p>
  
  <p>I tried running this on an actual device to see if it was just a simulator bug but the same thing happened on my iphone 6. Safe to say this is probably not going to work!</p>
  
  <p>Oh and just before we go any further, I am building the stack views in the following way:</p>
  
  <pre><code>[name - placeholder]
  [phone - placeholder]
  [address - placeholder]
  , setting a spacing of 8 and equal fill
  ,vertically stacking all of these stacks (3 into 1) and setting a spacing of 8
  , vertically stacking the details titles with the big stack and 8 spacing
  ,finally adding the title and button into the stack view with a spacing of 32.
  </code></pre>
  
  <p>I then apply some storyboard constraints: in this case just centre vertically &amp; horizontally, so the view is always centred and displays properly in both screen orientations.</p>
  
  <p>Even though this isn't aligned properly, this is the view before applying the stacks and constraints, this is what I want my endgame to look like: <a href="https://i.stack.imgur.com/4Uljj.png" rel="nofollow noreferrer">Looks kind of silly, but I want to figure this out so I can actually stack my paragraphs! (Image - 5)</a>.</p>
  
  <p>So now hopefully I've established that you can't really embed the label within a view as it doesn't render correctly at runtime, and you can't trick the stack into adding new lines.</p>
  
  <p><strong>How do I put a label with multiple lines into a stack view safely?</strong></p>
  
  <p>This is almost an offshoot question but when you try applying a stack to a paragraphed label, it sets the width of the label to be absolutely massive (sometimes it throws an error that interface builder can't render it <a href="https://i.stack.imgur.com/OjkPz.png" rel="nofollow noreferrer">Demonstrated here (Image 6)</a>. I've seen this happen a few times and don't really understand how xcode thinks that is a sensible option.</p>
  
  <p>I don't want to apply fixed widths to my labels or stacks because I'll only be left with another warning, and warnings are bad!</p>
  
  <p>I'm pretty lost at what to do, if anyone knows of a way this can be achieved I would be eternally grateful!</p>
  
  <p>Thanks</p>