Skip to content

Instantly share code, notes, and snippets.

@wleii
Last active October 26, 2017 08:02
Show Gist options
  • Save wleii/bed901c66ab7fec29878eea1a4bd79b7 to your computer and use it in GitHub Desktop.
Save wleii/bed901c66ab7fec29878eea1a4bd79b7 to your computer and use it in GitHub Desktop.
Resolution gesture ( UIPanGestureRecognizer and UIScreenEdgePanGestureRecognizer ) conflict
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