title: presentViewController from TableViewCell
body: <p>I have a TableViewController, TableViewCell and a ViewController. I have a button in the TableViewCell and I want to present ViewController with <code>presentViewController</code> (but ViewController doesn't have a view on storyboard). I tried using:</p>
  
  <pre><code>@IBAction func playVideo(sender: AnyObject) {
          let vc = ViewController()
          self.presentViewController(vc, animated: true, completion: nil)
  }
  </code></pre>
  
  <blockquote>
    <p>Error: Value of type TableViewCell has no member presentViewController</p>
  </blockquote>
  
  <hr>
  
  <p>Then, I tried </p>
  
  <p><code>self.window?.rootViewController!.presentViewController(vc, animated: true, completion: nil)</code></p>
  
  <blockquote>
    <p>Error: Warning: Attempt to present  whose view is not in the window hierarchy!</p>
  </blockquote>
  
  <hr>
  
  <p><em>What am I doing wrong? What should I do in order to presentViewController from TableViewCell? Also how can I pass data to the new presenting VC from TableViewCell?</em></p>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <pre><code>protocol TableViewCellDelegate
  {
     buttonDidClicked(result: Int)
  }
  
  class TableViewCell: UITableViewCell {
  
      @IBAction func play(sender: AnyObject) {
          if let id = self.item?["id"].int {
              self.delegate?.buttonDidClicked(id)
          }
      }
  }
  ----------------------------------------
  
  // in TableViewController
  
  var delegate: TableViewCellDelegate?
  func buttonDidClicked(result: Int) {
      let vc = ViewController()
      self.presentViewController(vc, animated: true, completion: nil)
  }
  </code></pre>
  
  <blockquote>
    <p>I receive error: Presenting view controllers on detached view controllers is discouraged</p>
  </blockquote>
  
  <p>(Please note that I have a chain of NavBar &amp; TabBar behind TableView.)</p>
  
  <hr>
  
  <p>I also tried</p>
  
  <pre><code> self.parentViewController!.presentViewController(vc, animated: true, completion: nil)
  </code></pre>
  
  <p>Same Error.</p>
  
  <hr>
  
  <p>Also tried,</p>
  
  <pre><code>self.view.window?.rootViewController?.presentViewController(vc, animated: true, completion: nil)
  </code></pre>
  
  <p>Same Error</p>