6

I have 1 Main View and 1 SubView:

Main View > SubView

I think that the Main View is "stealing" the events from the SubView.

For example, when I tap on the SubView, only the Main View GestureRecognizer is fire.

Here is my custom GestureRecognizer (which intercepts every touch event):

import UIKit
import UIKit.UIGestureRecognizerSubclass

class MainGestureRecognizer: UIGestureRecognizer {
    
    override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) {
        super.touchesBegan(touches, withEvent: event);
        //nextResponder() ??
        
        state = UIGestureRecognizerState.Began;
    }
 
    override func touchesMoved(touches: NSSet!, withEvent event: UIEvent!) {
        super.touchesMoved(touches, withEvent: event);
        //nextResponder() ??
        
        state = UIGestureRecognizerState.Changed;
    }
 
    override func touchesEnded(touches: NSSet!, withEvent event: UIEvent!) {
        super.touchesEnded(touches, withEvent: event);
        //nextResponder() ??
        
        state = UIGestureRecognizerState.Ended;
    }
 
    override func touchesCancelled(touches: NSSet!, withEvent event: UIEvent!) {
        super.touchesCancelled(touches, withEvent: event);
        //nextResponder() ??
        
        state = UIGestureRecognizerState.Cancelled;
    }
}

Maybe I should use nextResponder, but I have only found Obj-C code like:

[self.nextResponder touchesBegan:touches withEvent:event];

What's the trick to pass an event to the next responder in the responder chain?

Is there a way to pass touches through on the iPhone?

So the question is, what should I do to make the second event (the SubView Event) fire too?

Is there a function like nextResponder in Swift?

Community
  • 1
  • 1
Santa Claus
  • 984
  • 1
  • 12
  • 26

1 Answers1

1

Ôh ! Here is the Swift code for nextResponder :

https://stackoverflow.com/a/26510277/4135158

Community
  • 1
  • 1
Santa Claus
  • 984
  • 1
  • 12
  • 26
  • Would you mind posting some code? I couldn't figure out how that link fit into solving your (and my) problem. – Suragch Oct 05 '15 at 05:09