Search code examples
iosobjective-cuiviewgestureuitapgesturerecognizer

iOS Let UIGestureGestureRecognizer failed for other UIGestureGestureRecognizer?


I write UIView class called myView1 by extending one exit View called myView2. it has registered one UITapGestureRecognizer (called tap2) in myView2, and I also want to register one UITapGestureRecognizer (called tap1) in myView1. I want to system call tap1 first, then call tap2 if tap1 failed. So I call below method.

[tap2 requireGestureRecognizerToFail:tap1];

-(void)handleTap1:(UITapGestureRecognizer *) sender{
    if () {
        // let tap1 failed, then call tap2.
    }
}

The question is that : how to let tap1 failed, then call tap2. tap2 is the UITapGestureRecognizer of super class myView2.


Solution

  • A tap gesture could be recognized by one view at the same time refer to the iOS event response chain. For the same type gesture recognizer, requireGestureRecognizerToFail won't help you a lot, as I know.

    If the tap1 failed condition depends on your private logic, you should implement the event forward manually by yourself. If there are really touch gesture conflicts exist among them, implement the UITapGestureRecognizer/UIGestureRecognizer's delegate to identify their states including begin/move/end points.