Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's the trick to pass an event to the next responder in the responder chain?
    primarykey
    data
    text
    <p>Apple is really funny. I mean, they say that this works:</p> <pre><code>- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch* touch = [touches anyObject]; NSUInteger numTaps = [touch tapCount]; if (numTaps &lt; 2) { [self.nextResponder touchesBegan:touches withEvent:event]; } else { [self handleDoubleTap:touch]; } } </code></pre> <p>I have a View Controller. Like you know, View Controllers inherit from UIResponder. That View Controller creates a MyView object that inherits from UIView, and adds it as a subview to it's own view.</p> <p>So we have:</p> <p>View Controller > has a View (automatically) > has a MyView (which is a UIView).</p> <p>Now inside of MyView I put that code like above with a NSLog that prints "touched MyView". But I forward the event to the next responder, just like above. And inside the ViewController I have another touchesBegan method that just prints an NSLog a la "touched view controller".</p> <p>Now guess what: When I touch the MyView, it prints "touched MyView". When I touch outside of MyView, which is the view of the VC then, I get a "touched view controller". So both work! But what doesn't work is forwarding the event. Because now, actually the next responder should be the view controller, since there's nothing else inbetween. But the event handling method of the VC is never called when I forward it.</p> <p>%$&amp;!§!!</p> <p>Ideas?</p> <p><strong>Figured out weird stuff</strong> MyView's next responder is the view of the view controller. That makes sense, because MyView is a subview of that. But I didn't modify this UIView from the view controller. it's nothing custom. And it doesn't implement any touch event handling. Shouldn't the message get passed on to the view controller? How could I just let it pass? If I remove the event handling code in MyView, then the event arrives nicely in the view controller.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload