0

This must be obvious to everyone but me.

Once I have a popup controller displayed (it's not fullscreen), I can't get the view controller underneath it to respond to swipe gestures. Everything works correctly as long as the popup isn't launched. Once it is on screen, the initial controller does not respond to swipes on its main view.

Here's the code:

  ///    One for each supported direction: used to increment/decrement date displayed
    func setupGestureRecognizers() {
        let leftRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(self.swipeInDirection(_:)))
        leftRecognizer.direction = .left
        leftRecognizer.cancelsTouchesInView = false
        view.addGestureRecognizer(leftRecognizer)
        leftRecognizer.delegate = self

        let rightRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(self.swipeInDirection(_:)))
        rightRecognizer.direction = .right
        rightRecognizer.cancelsTouchesInView = false
        view.addGestureRecognizer(rightRecognizer)
        rightRecognizer.delegate = self
        print("recognizers are armed")
     }


       @objc
        func swipeInDirection(_ gesture: UISwipeGestureRecognizer) {
            if gesture.direction == .right {
                dayOffset -= 1
            } else {
                dayOffset += 1
            }
            let name = Notification.Name(rawValue: "DayOffsetChanged")
            let userInfo = ["DayOffsetChanged": dayOffset]
            NotificationCenter.default.post(Notification(name: name, object: nil, userInfo: userInfo))
            print("posted: \(name.rawValue)")
        }

    /// Launch the popup
    /// - Parameter sourceView: cell which was selected
    @objc
    func launchAppController(sourceView: UIView) {
        let popoverVC = PageViewController(nibName: nil, bundle: nil)
        popoverVC.modalPresentationStyle = .popover
        popoverVC.preferredContentSize = CGSize(width: self.view.frame.width * 0.7, height: self.view.frame.height * 0.4)
        if let popoverController = popoverVC.popoverPresentationController {
            popoverController.sourceView = sourceView
            popoverController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY + 20, width: 0, height: 0)
            popoverController.permittedArrowDirections = .init(rawValue: 0)
            popoverController.delegate = self
            popoverVC.view.backgroundColor = UIColor.red.withAlphaComponent(0.2)
            popoverController.backgroundColor = UIColor(white: 1, alpha: 0.01)
        }
        present(popoverVC, animated: true, completion: nil)
    }

Is there a setting which allows interaction while the popup is displayed?

Mozahler
  • 4,958
  • 6
  • 36
  • 56

0 Answers0