title: How to dismiss UIPopoverPresentationController on tap inside it. (iOS, Swift)
body: <p>I've been successfully able to implement a popviewcontroller, which contains a tableview of 4 cells. I want to close the popViewController when the cell is selected, but I cannot seem to do this.  In my tableViewController, I have a method inside didSelectRowAtIndexPath, which calls this MasterViewController's method "updateToSelectedTab".  I am able to print out the indexpath of the selected cell here, but I cannot remove the popViewController when the cell is selected.  How do I do this?</p>
  
  <p><a href="https://i.stack.imgur.com/MhMHG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MhMHG.png" alt="enter image description here"></a></p>
  
  <p>//Here is our MasterViewController class</p>
  
  <pre><code>@IBAction func pop(sender: AnyObject) {
  
      let contentView = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("popViewController") as! PopViewController
      contentView.modalPresentationStyle = UIModalPresentationStyle.Popover
      contentView.preferredContentSize = CGSizeMake(aButton.frame.width, 240.0)
  
      let popoverMenuViewController = contentView.popoverPresentationController!
      popoverMenuViewController.delegate = self
      popoverMenuViewController.permittedArrowDirections = UIPopoverArrowDirection.Any
      popoverMenuViewController.sourceView = view
      popoverMenuViewController.permittedArrowDirections = UIPopoverArrowDirection(rawValue:0)
  
      popoverMenuViewController.sourceRect = CGRectMake(aButton.frame.origin.x, aButton.frame.origin.y - 60, aButton.frame.width, aButton.frame.height)
      presentViewController(contentView, animated: true, completion: nil)
  }
  
  func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -&gt; UIModalPresentationStyle {
      return UIModalPresentationStyle.None
  }
  
  //This method is called from didSelectRowAtIndexPath of the View Controller that handles the UIPopoverPresentationController
  func updateToSelectedTab(tab: Int){
      print("Current tab \(tab)")
      //Need to dismiss controller here
  
  }
  </code></pre>