开发者

How to recognise gesture in superview?

I have a view (parent) and a subview (child). The child is a UIControl, responding to UIControlEventTouchDownInside, the parent has a swipe recogniser. I would like to catch swipes even if they start in the child.

Question: how can I recognise the swipe before the tap? Is there any way to tell iphone that gestures in the parent come before gestures in the child?

Thanks for your help!

Edit I just changed the child to be a UIControl (开发者_StackOverflowinstead of using a tap recogniser). I'm not sure this matters much to the answer to this question but I thought I'd mention it anyway.

Edit 2

In response to the two answers I have added the tap recogniser to the child again and tried to delay (and fail) the tap recognition so that I can swipe across the big view (parent) containing the child. No luck so far.

Edit 3

I would really like to keep the child a UIControl and use UITouchDownInside rather than a tap recogniser because I want to use the down event rather than the up event.

Edit 4

Now the swipe gets detected but in the child, none of the following gets detected: UIControlEventTouchDragOutside, UIControlEventTouchDragExit , UIControlEventTouchCancel and I need at least one of these to detect when the user doesn't actually mean to tap on the child : /


Check the - (void)requireGestureRecognizerToFail:(UIGestureRecognizer *)otherGestureRecognizer in UIGestureRecognizer. To tap, the swipe gesture has to fail.


You can use the [swipeGesture delaysTouchesBegan] message to delay the touch events being delivered to the child control.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜