title: Dismiss Popover after touch
body: <p>I've created a popover inside my <code>MainViewController</code> when some button its touched using the <code>UIPopoverPresentationController</code> and set like it's delegate like it's showed in the WWDC 2014, in the following way :</p>
  
  <blockquote>
    <p><strong>MainViewController.swift</strong> </p>
  </blockquote>
  
  <pre><code>class MainViewController : UIViewController, UIPopoverPresentationControllerDelegate {
  
     @IBAction func showPopover(sender: AnyObject) {
  
        var popoverContent = self.storyboard?.instantiateViewControllerWithIdentifier("PopOverViewController") as UIViewController
  
        popoverContent.modalPresentationStyle = UIModalPresentationStyle.Popover
        var popover = popoverContent.popoverPresentationController
  
        popoverContent.preferredContentSize = CGSizeMake(250, 419)
        popover!.delegate = self
        popover!.sourceView = self.view
        popover!.sourceRect = CGRectMake(180,85,0,0)
  
        self.presentViewController(popoverContent, animated: true, completion: nil)        
     }  
  }
  </code></pre>
  
  <p>The popover have a View inside  it and when the View it's clicked with a Tap Gesture Recognizer I show  <code>LastViewController</code> using a modal segue, the modal segue is created through the Interface Builder, not in code using an action to present the another <code>LastViewController</code></p>
  
  <p>Once the <code>LastViewController</code> is dismissed and I'm back in the <code>MainViewController</code> the popover remains open.</p>
  
  <p>Inside the <strong>PopOverController</strong> I only have the default code nothing more.</p>
  
  <blockquote>
    <p><strong>LastViewController.swift</strong> </p>
  </blockquote>
  
  <pre><code>@IBAction func dismissVIew(sender: AnyObject) {        
      self.dismissViewControllerAnimated(true, completion: nil)
  }
  </code></pre>
  
  <p>The above code is used to dismiss the <code>LastViewController</code> once the button inside is touched. </p>
  
  <blockquote>
    <p><strong>Storyboard</strong></p>
  </blockquote>
  
  <p><img src="https://i.stack.imgur.com/PDfkn.png" alt="enter image description here"></p>
  
  <p>How can I dismiss the popover once the another <code>LastViewController</code> it's visible, or before the another <code>LastViewController</code> should be opened?</p>
  
  <p>Thanks in advance</p>