title: Adjust the height of scrollview according to the height of his child tableview in SWIFT
body: <p>I have a viewController, with a tableview inside a scrollview.</p>
  
  <p>I need to update programmatically the height of the tableview, and then, the height of the scrollview (scrollview's height depends on tableview's height).</p>
  
  <pre><code>-my View Controller
    -View
      -ScrollView
        -Container View
          -TableView
  </code></pre>
  
  <p>So I wrote this code in the viewDidAppear of my viewController :</p>
  
  <pre><code> override func viewDidAppear(animated: Bool) {
  
      super.viewDidAppear(animated)
  
      var frame:CGRect = self.tableView.frame
      frame.size.height = tableView.contentSize.height
      self.tableView.frame = frame
  
      scrollView.contentSize=CGSizeMake(scrollView.frame.size.width, tableView.frame.origin.y + tableView.frame.height)
  
   }
  </code></pre>
  
  <p>If I check in the console, viewDidAppear is called BEFORE all the cellForRowAtIndexPath. In this case, everything works as I want.</p>
  
  <p>In my viewController, I have a button that opens a modalViewController. In this modalViewController,  I add a new data in my tableview (so, a new cell).</p>
  
  <p>When I close my modalViewController with dismissViewControllerAnimated, viewDidAppear is called but AFTER all the cellForRowAtIndexPath.
  My viewController is not displayed correctly, the tableview is cropped, I cannot scroll to the bottom of my tableView. My code doesn't work.</p>
  
  <p>I'm working with Swift and auto layout.</p>