This is my swipe gesture recognizer. It's working so far, but whenever I try to push a View Controller on Swipe Down it would run the code block and I would get the print in the console. But won't push any view controller.
Also, it doesn't return o throw any error or warning. So not sure how to go about this:
Expected behavior: On swipe down, push UIAlertController
Also, it doesn't return o throw any error or warning. So not sure how to go about this:
Expected behavior: On swipe down, push UIAlertController
Code Block class GestureManager: NSObject, TVDocumentViewControllerDelegate { var appDelegate = UIApplication.shared.delegate as! AppDelegate var vc: UIViewController? init(vc: UIViewController) { self.vc = vc let swipeRight = UISwipeGestureRecognizer(target: vc, action: #selector(respondToSwipeGesture(_:))) swipeRight.direction = .right let swipeLeft = UISwipeGestureRecognizer(target: vc, action: #selector(respondToSwipeGesture(_:))) swipeLeft.direction = .left let swipeUp = UISwipeGestureRecognizer(target: vc, action: #selector(respondToSwipeGesture(_:))) swipeUp.direction = .up let swipeDown = UISwipeGestureRecognizer(target: vc, action: #selector(respondToSwipeGesture(_:))) swipeDown.direction = .down vc.view.addGestureRecognizer(swipeRight) vc.view.addGestureRecognizer(swipeLeft) vc.view.addGestureRecognizer(swipeUp) vc.view.addGestureRecognizer(swipeDown) } @objc func respondToSwipeGesture(_ gesture : UIGestureRecognizer) { if let swipeGesture = gesture as? UISwipeGestureRecognizer { switch swipeGesture.direction { case .right: print("swiped right!") case .left: print("Swiped left") case .up: print("Swiped up") case .down: print("Swiped down") let alertController = UIAlertController(title: "Test", message: "Test message", preferredStyle: .alert ) appDelegate.appController?.navigationController.pushViewController(alertController, animated: true) default: return } } } }