简体   繁体   中英

UIPanGestureRecognizer requireGestureRecognizerToFail delays UIScrollView

i have a UIPanGestureRecognizer on my rootViewControllers view

that controls only 2 finger swipe ( min and max are set on 2 )

I have a couple of UITableView and UIScrollView on my rootViewControllers view. But the 2 finger swipe should always have number 1 priority

so i put a requireGestureRecognizerToFail on my UITableView and UIScrollView's panGesture property.

this works perfectly but now when i pan my UITableView and UIScrollView, it doesn't move until i stop swiping.

Is there a solution for this?

i have added a sample project to display what the problem is: https://github.com/avalanched/UIScrollViewTest

You will need to allow the gesture recognizers to simultaneously recognize by setting the delegate on all the gesture recognizers and implementing gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: .

See Apple's UIGestureRecognizerDelegate Documentation .

You also need to remove the requireGestureRecognizerToFail calls, these are what causes the delay.

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