title: instantly scroll tableView to indexPath
body: <p>I have to scroll tableView to indexPath immediately after my screen appears. Here is what I've tried but it doesn't work at start. It works only when tableView has loaded and then I press a button which scrolls tableView.</p>
  
  <pre><code>func scrollTableViewToCell() {
      let indexPath = NSIndexPath(forItem: 8, inSection: 1)
      self.tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: .Middle, animated: true)
  }
  </code></pre>
  
  <p>I've also tried this but it doesn't work as I need:</p>
  
  <pre><code>func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
      println(indexPath)
      println(NSIndexPath(forRow: tableView.indexPathsForVisibleRows()!.last!.row, inSection: 2))
      if indexPath == NSIndexPath(forRow: tableView.indexPathsForVisibleRows()!.last!.row, inSection: 0) {
          scrollTableViewToCell()
      }
  }
  </code></pre>
  
  <p>I've also tried this)</p>
  
  <pre><code>override func viewDidLayoutSubviews() {
      self.view.layoutIfNeeded()
      scrollTableViewToCell()
  }
  </code></pre>
  
  <p>Can someone tell me how to know when tableView has loaded all cells and then scroll it to <em>NSIndexPath(forItem: 8, inSection: 1)</em> ?</p>
  
  <p><strong>UPDATE::</strong></p>
  
  <p>Here is how I load the data to tableView:</p>
  
  <pre><code>func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
      return years.count
  }
  
  func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      return allInfo[years[section]]!.count
  }
  
  func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
      var cell = tableView.dequeueReusableCellWithIdentifier("tutionTableViewCell") as! TuitionTableViewCell
      cell.selectionStyle = .None
  
      let info = allInfo[years[indexPath.section]]! as [String: String?]
  
      cell.monthLabel.text = months[indexPath.row]
      if info[months[indexPath.row]]! != nil {
          cell.tuitionLabel.hidden = false
          cell.tuitionLabel.text = info[months[indexPath.row]]!
      } else {
          cell.tuitionLabel.hidden = true
      }
      if info[months[indexPath.row]]! == "Nog te betalen" {
          cell.monthLabel.textColor = UIColor(hex: 0xff0000).colorWithAlphaComponent(0.87)
          cell.tuitionLabel.textColor = UIColor(hex: 0xff0000).colorWithAlphaComponent(0.87)
      } else {
          cell.monthLabel.textColor = UIColor.blackColor().colorWithAlphaComponent(0.87)
          cell.tuitionLabel.textColor = UIColor.blackColor().colorWithAlphaComponent(0.87)
      }
      return cell
  }
  
  func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -&gt; String? {
      return years[section]
  }
  
  func tableView(tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
      let header: UITableViewHeaderFooterView = view as! UITableViewHeaderFooterView
      header.textLabel.font = UIFont(name: "Roboto-Regular", size: 16)
      header.textLabel.text = self.tableView(self.tableView, titleForHeaderInSection: section)
      let headerFrame = header.frame
      header.textLabel.frame = headerFrame
      header.textLabel.textColor = UIColor.blackColor().colorWithAlphaComponent(0.54)
      header.textLabel.backgroundColor = UIColor(hex: 0xf9f9f9)
      header.contentView.backgroundColor = UIColor(hex: 0xf9f9f9)
  }
  
  func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -&gt; CGFloat {
      return 35
  }
  </code></pre>
  
  <p><strong>SECOND UPDATE::</strong></p>
  
  <p>My hardcoded data: </p>
  
  <pre><code>var years: [String] = ["2015", "2016", "2017"]
  var months: [String] = ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"]
  var allInfo: [String: [String: String?]] = [String: [String: String?]]()
  
  override func viewDidLoad() {
      self.tableView.separatorStyle = .None
      self.tableView.rowHeight = UITableViewAutomaticDimension
      self.tableView.estimatedRowHeight = 150.0
  
      allInfo[years[0]] = ["Januari": "300,00", "Februari": "300,00", "Maart": "300,00", "April": "300,00", "Mei": "300,00", "Juni": "300,00", "Juli": "300,00", "Augustus": "300,00", "September": "300,00", "Oktober": "300,00", "November": "300,00", "December": "300,00"]
      allInfo[years[1]] = ["Januari": "300,00", "Februari": "300,00", "Maart": "300,00", "April": "300,00", "Mei": "300,00", "Juni": "300,00", "Juli": "300,00", "Augustus": "300,00", "September": "Nog te betalen", "Oktober": nil, "November": nil, "December": nil]
      allInfo[years[2]] = ["Januari": nil, "Februari": nil, "Maart": nil, "April": nil, "Mei": nil, "Juni": nil, "Juli": nil, "Augustus": nil, "September": nil, "Oktober": nil, "November": nil, "December": nil]
  
      tableView.reloadData()
      scrollTableViewToCell()
  }
  </code></pre>