Disallow UIScrollView from catching subviews touch

2019-05-17 17:10发布

问题:

I've got a UIScrollView covered with a custom UIView which desperatly needs to listen to all the touch events that happen inside of him.

At first, all I was getting was touchesBegan: and touchesCancelled: events. No touchesMoved:, no touchesEnded:. In fact, all the dragging gestures where being canceled by the above UIScrollView. This was solved by the following setting:

_scrollView.canCancelContentTouches = NO;

Now, the behaviour changes depending on the "length in time" of the first touch on the UIView. If it's short, then the relative dragging is managed as it was a scroll for the UIScrollView. If it's long, then I'm getting the touchesMoved: events inside my UIView.

What I want is to always receive touchesMoved: inside my UIView. How can I make it?

回答1:

Have you tried modifying the delaysContentTouches property of your UIScrollView? I had a similar issue, solved it.