简体   繁体   中英

UISwipeGestureRecognizer conflicts with UIScrollView

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!

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM