title: Swift Popover closing when touching background
body: <p>I have a popover that is being called and I want the only way to close the popover is by clicking the Close button, not by taping on the background. Currently my code to launch the popover is like this:</p>
  
  <pre><code> let popover = storyboard?.instantiateViewController(withIdentifier: "PopoverVC") as! PopOverViewController
  
          popover.modalPresentationStyle = .popover
          popover.popoverPresentationController?.delegate = self as? UIPopoverPresentationControllerDelegate
  
  
          popover.popoverPresentationController?.sourceView = self.view
          popover.popoverPresentationController?.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
  
          popover.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
  
          popoverPresentationController?.passthroughViews = nil
  
  
  
          dimView.isHidden = false
  
          popover.dimView = self.dimView
  
          self.present(popover, animated: false)
  </code></pre>
  
  <p>I have a UIview in the background that I use to dim the background when the popover comes up but when you tap on the background, it closes the popover. How can I keep the popover open? I thought the <code>popoverPresentationController?.passthroughViews = nil</code> was supposed to resolve this but it hasn't.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Adding my PopOverViewController Class:</p>
  
  <pre><code>    class PopOverViewController: UIViewController, UIPopoverPresentationControllerDelegate {
  
  
      var dimView:UIView?
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
  
          // Do any additional setup after loading the view.
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
  
      func popoverPresentationControllerShouldDismissPopover(_ popoverPresentationController: UIPopoverPresentationController) -&gt; Bool {
  
          print ("test")
  
          return false
      }
  
  
      @IBAction func closeButton(_ sender: Any) {
  
          self.dismiss(animated: false, completion: nil)
  
          dimView?.isHidden = true
  
  
      }
  
  }
  </code></pre>