4

The view hierarchy is like this: A normal UIView is at the bottom, and a UIScrollView is added on the bottom whose contentSize is equal to the size of the bottom view.Then, a "UISwipeGestureRecognizer" is added on the bottom view whose swipe direction is "UISwipeGestureRecognizerDirectionRight".

What I want to do is that when swipe up and down the scrollView will move and when swipe right the swipeGesture will be triggered.

But the problem is that the swipeGesture is never detected. How to solve the problem? Thanks!

itenyh
  • 1,921
  • 2
  • 23
  • 38
  • Your question's kind of confusing, but is the user interaction enabled in the swipe's view? – Lyndsey Scott Sep 05 '14 at 02:18
  • Yes, it is. If I do not add the UIScrollView ,but only the UISwipeGestureRecognizer is added on the bottom view. The gesture can be detected. So it seems that the swipe gesture conflicts with the scrollView. @LyndseyScott – itenyh Sep 05 '14 at 02:25
  • Try adding the gesture on the scrollView,I'm not sure. – mengxiangjian Sep 05 '14 at 02:48
  • @mengxiangjian Tried. Not Work~~~ – itenyh Sep 05 '14 at 02:50
  • 6
    I have solved the problem by returning YES on the delegate methond: - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer – itenyh Sep 05 '14 at 03:01

1 Answers1

1

Transferring itenyh's own answer to proper place.

By returning YES on the following UIGestureRecognizerDelegate's method will do the job:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return YES;
}
Willy
  • 9,681
  • 5
  • 26
  • 25