Last active
October 26, 2017 08:02
-
-
Save wleii/bed901c66ab7fec29878eea1a4bd79b7 to your computer and use it in GitHub Desktop.
Resolution gesture ( UIPanGestureRecognizer and UIScreenEdgePanGestureRecognizer ) conflict
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
extension UIScrollView { | |
//当UIScrollView滑动手势与 UIScreenEdgePanGestureRecognizer手势同在,手势沿响应链向下传递 | |
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool { | |
// 如果侧滑 Back 手势以及侧滑滚动手势同时响应,则调用 `open func require(toFail otherGestureRecognizer: UIGestureRecognizer)`使其侧滑滚动手势 failed | |
if gestureRecognizer is UIPanGestureRecognizer && otherGestureRecognizer is UIScreenEdgePanGestureRecognizer { | |
gestureRecognizer.require(toFail: otherGestureRecognizer) | |
// 允许手势沿响应链向下传递 | |
return true | |
} | |
return false | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment