Last active
August 3, 2018 08:44
-
-
Save grifas/7e912692de787afb669b62b37d3f5fe8 to your computer and use it in GitHub Desktop.
SwipeGesture in scrollView: require to fail.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChildViewController: UIViewController { | |
func addSwipeGesture() { | |
let leftGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(swipe)) | |
let rightGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(swipe)) | |
leftGestureRecognizer.delegate = self | |
rightGestureRecognizer.delegate = self | |
leftGestureRecognizer.direction = UISwipeGestureRecognizerDirection.left | |
rightGestureRecognizer.direction = UISwipeGestureRecognizerDirection.right | |
view.addGestureRecognizer(leftGestureRecognizer) | |
view.addGestureRecognizer(rightGestureRecognizer) | |
parentScrollView.panGestureRecognizer.require(toFail: leftGestureRecognizer) | |
parentScrollView.panGestureRecognizer.require(toFail: rightGestureRecognizer) | |
} | |
} | |
extension ChildViewController: UIGestureRecognizerDelegate { | |
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { | |
// return true/false to enable/disable the left/right gesture | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment