title: Nested UIStackview issue, removing them cause a crash. How to correctly remove them?
body: <p>in an attempt to create a spreadsheet like table without using UICollectionViews, I decided to use nested UIStackViews. </p>
  
  <p>However, since I am using them in a UITableViewCell, and programmatically create them, I have to remove them from cell, otherwise, when it redraws the cell, the new views will overlap with the old ones.</p>
  
  <p>But when removing them from parent view, it crashes. How to correctly remove nested UIStackViews?</p>
  
  <p>My Code to create nested UIStackViews:</p>
  
  <pre><code>        let table = UIStackView()
          table.axis = .Vertical
          table.spacing = 8
  
          let json = JSON(data: jsonNew)
  
          for i in 0..&lt;json["Rows"].count{
  
              let horizontal = UIStackView()
              horizontal.axis = .Horizontal
              horizontal.spacing = 8
  
              for j in 0..&lt;json["Rows"][i]["Column"].count{
  
                  let label = UILabel()
                  label.text = json["Rows"][i]["Column"][j].string!
                  label.lineBreakMode = .ByWordWrapping
                  label.numberOfLines = 0
                  label.font = label.font.fontWithSize(12)
                  horizontal.addArrangedSubview(label)
  
              }
  
              table.addArrangedSubview(horizontal)
  
          }
  </code></pre>
  
  <p>This is how I remove all views from cell:</p>
  
  <pre><code>for myview in view.subviews{
       myview.removeFromSuperview()
  }
  </code></pre>
  
  <p>This is the error:</p>
  
  <blockquote>
    <p>2016-05-17 11:37:58.745 TestProject[678:26088] _UIConstraintBasedLayoutLogUnsatisfiable is OFF
    2016-05-17 11:38:16.563 TestProject[678:26088] <strong>* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:
    '{objective 0x12faebf00: &lt;1100:16, 760:-6.10352e-05, 750:100, 251:563,
    250:-512.5> +
    &lt;760:-1>*0x12ddfbd00:UISV-text-width-disambiguation.negError{id:
    13416} +
    &lt;760:1>*0x12ddfbd00:UISV-text-width-disambiguation.posErrorMarker{id:
    13415} +
    &lt;760:-1>*0x12ddfbd50:UISV-text-width-disambiguation.negError{id:
    13431} +
    &lt;760:1>*0x12ddfbd50:UISV-text-width-disambiguation.posErrorMarker{id:
    13430} + &lt;750:1, 250:1>*0x12f80df30.negError{id: 13501} + &lt;750:1,
    250:1>*0x12f80f000.negError{id: 13499} +
    &lt;250:1>*0x12f84df70:UISV-alignment.marker{id: 13578} +
    &lt;250:4.6875>*0x12f85ee40:UISV-canvas-connection.marker{id: 13524} +
    &lt;750:1, 250:1>*0x12f873b40.posErrorMarker{id: 13486} +
    &lt;1100:1>*0x12f8a5730:UIView-Encapsulated-Layout-Width.marker{id:
    13587} + &lt;250:-1>*0x12f8b54e0:UISV-alignment.marker{id: 13557} +
    &lt;250:-4.6875>*0x12f8d1d70:UISV-canvas-connection.marker{id: 13522} +
    &lt;760:-1>*0x12f904f30:UISV-text-width-disambiguation.negError{id:
    13412} +
    &lt;760:1>*0x12f904f30:UISV-text-width-disambiguation.posErrorMarker{id:
    13411} + &lt;760:1>*0x12f904fa0:UISV-spacing.marker{id: 13413} +
    &lt;251:-1>*0x12f98e950.marker{id: 12953} +
    &lt;251:1>*0x12f9b0580.marker{id: 12949} +
    &lt;760:1>*0x12f9cec00:UISV-canvas-connection.marker{id: 13406} +
    &lt;250:4.6875>*0x12fa05f30:UISV-spacing.marker{id: 13535} + &lt;999:1,
    250:-5.6875>*0x12fa11cd0:UISV-fill-proportionally.negError{id: 13530}
    + &lt;999:1, 250:5.6875>*0x12fa11cd0:UISV-fill-proportionally.posErrorMarker{id:
    13529} + &lt;1100:1>*0x12fa146d0.marker{id: 13000} + &lt;750:1,
    250:1>*0x12fa27ab0.posErrorMarker{id: 13492} +
    &lt;1100:-1>*0x12fa3cc90.marker{id: 12998} + &lt;750:1,
    250:1>*0x12fa3cd80.negError{id: 13511} + &lt;750:1,
    250:1>*0x12fa3ea20.negError{id: 13513} +
    &lt;250:1>*0x12fa47260:UISV-alignment.marker{id: 13572} + &lt;750:1,
    251:1>*0x12fa4e480.negError{id: 13020} + &lt;1100:-1,
    251:1>*0x12fa55880.marker{id: 14140} +
    &lt;250:1>*0x12fa5bc10:UISV-alignment.marker{id: 13581} + &lt;750:1,
    250:1>*0x12fa6a5c0.negError{id: 13495} + &lt;750:1,
    250:1>*0x12fa711c0.negError{id: 13483} + &lt;994:1,
    250:-5.6875>*0x12fa78560:UISV-fill-proportionally.negError{id: 13547}
    + &lt;994:1, 250:5.6875>*0x12fa78560:UISV-fill-proportionally.posErrorMarker{id:
    13546} + &lt;250:-1>*0x12fa7c820:UISV-alignment.marker{id: 13565} +
    &lt;250:-1>*0x12fa7c870:UISV-alignment.marker{id: 13567} +
    &lt;250:1>*0x12fa7c8c0:UISV-alignment.marker{id: 13569} +
    &lt;250:1>*0x12fa7f990:UISV-alignment.marker{id: 13575} +
    &lt;250:4.6875>*0x12fa7fc20:UISV-spacing.marker{id: 13527} +
    &lt;250:4.6875>*0x12fa93c40:UISV-spacing.marker{id: 13531} + &lt;750:1,
    250:1>*0x12fa94dd0.negError{id: 13517} + &lt;750:-1,
    250:4.6875>*0x12fa980e0:UISV-hiding.marker{id: 13550} +
    &lt;250:-1>*0x12fa98d50:UISV-alignment.marker{id: 13559} + &lt;750:1,
    250:1>*0x12fa990f0.negError{id: 13505} + &lt;750:-1,
    250:4.6875>*0x12faad3d0:UISV-hiding.marker{id: 13551} + &lt;750:1,
    251:1>*0x12fab93e0.negError{id: 13022} + &lt;750:1,
    250:1>*0x12fac5ee0.negError{id: 13481} +
    &lt;250:7>*0x12facbf60:UISV-canvas-connection.marker{id: 13552} + &lt;750:1,
    250:1>*0x12fad6cb0.negError{id: 13489} +
    &lt;250:4.6875>*0x12fadb570:UISV-spacing.marker{id: 13543} +
    &lt;250:1>*0x12fae21d0:UISV-alignment.marker{id: 13584} +
    &lt;250:-7>*0x12fae8940:UISV-canvas-connection.marker{id: 13554} +
    &lt;750:1, 250:1>*0x12faec7c0.negError{id: 13519} +
    &lt;760:-1>*0x12fc0f8a0:UISV-canvas-connection.marker{id: 13403} +
    &lt;251:-1>*0x12fc1a8a0.marker{id: 12975} +
    &lt;760:1>*0x12fc276f0:UISV-spacing.marker{id: 13409} +
    &lt;760:1>*0x12fc54e40:UISV-spacing.marker{id: 13417} +
    &lt;760:-1>*0x12fc54e90:UISV-text-width-disambiguation.negError{id:
    13429} +
    &lt;760:1>*0x12fc54e90:UISV-text-width-disambiguation.posErrorMarker{id:
    13428} + &lt;251:-1>*0x12fc6dd10.marker{id: 12972} +
    &lt;1100:1>*0x12fc6e830.marker{id: 12969} +
    &lt;760:-1>*0x12fc75b80:UISV-text-width-disambiguation.negError{id:
    13424} + &lt;760:1>*0x12fc75bf0:UISV-spacing.marker{id: 13425} +
    &lt;760:-1>*0x12fc78190:UISV-text-width-disambiguation.negError{id:
    13420} +
    &lt;760:1>*0x12fc78190:UISV-text-width-disambiguation.posErrorMarker{id:
    13419} + &lt;760:1>*0x12fc78200:UISV-spacing.marker{id: 13421} +
    &lt;251:-1>*0x12fc8fd20.marker{id: 12957} +
    &lt;1100:1>*0x12fc95e90.marker{id: 12963} +
    &lt;250:7>*0x12fc960b0.marker{id: 12955} +
    &lt;250:4.6875>*0x12fd06e40:UISV-spacing.marker{id: 13533} + &lt;750:1,
    250:1>*0x12fd07210.negError{id: 13507} + &lt;996:1,
    250:-5.6875>*0x12fd1a3a0:UISV-fill-proportionally.negError{id: 13538}
    + &lt;996:1, 250:5.6875>*0x12fd1a3a0:UISV-fill-proportionally.posErrorMarker{id:
    13537} + &lt;995:1,
    250:-5.6875>*0x12fd1b3f0:UISV-fill-proportionally.negError{id: 13542}
    + &lt;995:1, 250:5.6875>*0x12fd1b3f0:UISV-fill-proportionally.posErrorMarker{id:
    13541} + &lt;250:4.6875>*0x12fd1bd50:UISV-spacing.marker{id: 13539} +
    &lt;993:1, 250:-5.6875>*0x12fd1c370:UISV-fill-proportionally.negError{id:
    13549} + &lt;993:1,
    250:5.6875>*0x12fd1c370:UISV-fill-proportionally.posErrorMarker{id:
    13548} + &lt;250:-1>*0x12fd1e670:UISV-alignment.marker{id: 13561} +
    &lt;250:-1>*0x12fd1e6c0:UISV-alignment.marker{id: 13563} +
    &lt;750:0.00277778>*UILabel:0x12f884240'2016-04-11'.Width{id: 13061} +
    &lt;750:0.00277778>*UILabel:0x12fa2f410'2031839'.Width{id: 13031} +
    &lt;750:0.00277778>*UILabel:0x12fa2fd90'OTOTAY İÇ VE DIŞ
    PAZ.A.Ş.'.Width{id: 13037} +
    &lt;750:0.00277778>*UILabel:0x12fa52010'TL'.Width{id: 13055} +
    &lt;750:0.00277778>*UILabel:0x12fafa3d0'MAHMUT ÇETİNTÜRK'.Width{id:
    13043} + &lt;750:0.00277778>*UILabel:0x12fafa6a0'15000,00'.Width{id:
    13049} + &lt;760:0>*UIStackView:0x12fa081c0.Width{id: 13152} + &lt;760:0,
    750:-0.00277778>*UIStackView:0x12fb2b740.Width{id: 13067} +
    &lt;760:0>*UIStackView:0x12fc44970.Width{id: 13322} +
    &lt;760:0>*UIStackView:0x12fc65df0.Width{id: 13237}}: internal error. 
    Setting empty vector for variable
    UILabel:0x12f905720'6955677'.Width{id: 13371}.'
        *</strong> First throw call stack:
        (0x18221ae38 0x18187ff80 0x18221ad80 0x182b52de0 0x182ccf4d4 0x182b4fcc8 0x182b53108 0x182b50d18 0x182b53928 0x182b585e4
    0x182b4d010 0x182b4cd78 0x187464c80 0x187357368 0x187356c1c
    0x182b4cd50 0x187356ac4 0x1876702c4 0x1873554e8 0x100143634
    0x100148164 0x1876b2f40 0x1876b3120 0x1876b6a2c 0x1874a9500
    0x1874a923c 0x1874a8ebc 0x187448aa0 0x1876a1a34 0x1876b7b74
    0x1874487ac 0x1873580e4 0x184cfea28 0x184cf9634 0x184cf94f4
    0x184cf8b24 0x184cf886c 0x184cf1dd8 0x1821d07b0 0x1821ce554
    0x1821ce984 0x1820f8d10 0x1839e0088 0x1873c5f70 0x100107234
    0x181c968b8)
        libc++abi.dylib: terminating with uncaught exception of type NSException</p>
  </blockquote>