title: Dismiss popover viewController when tapped elsewhere
body: <p>I'm presenting a popover viewController on top of a UITableView. How can i dismiss this popover when tapped outside of it? I'm trying to call it from the didSelectRow method, but the tap isn't detected. Any suggestion?
  Thanks!
  this is my code:</p>
  
  <pre><code>    let addFriendsPopoverViewController = storyboard?.instantiateViewController(withIdentifier: "HomePopOver") as! HomePopOverViewController
      addFriendsPopoverViewController.index = (sender.tag)!
      addFriendsPopoverViewController.delegate = self
      addFriendsPopoverViewController.isModalInPopover = true
      addFriendsPopoverViewController.modalPresentationStyle =   UIModalPresentationStyle.popover
      addFriendsPopoverViewController.preferredContentSize = CGSize(width: 210, height: 40)
      let popoverMenuViewController = addFriendsPopoverViewController.popoverPresentationController
      popoverMenuViewController!.permittedArrowDirections = .down
      popoverMenuViewController!.delegate = self
      popoverMenuViewController!.sourceView = self.view
      popoverMenuViewController!.sourceRect = CGRect(
          x: UIScreen.main.bounds.width  - 105,
          y: 50,
          width: 1,
          height: 1)
      present(
          addFriendsPopoverViewController,
          animated: true,
          completion: nil)
  </code></pre>