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

前端 未结 8 994
悲&欢浪女
悲&欢浪女 2020-12-05 14:44

Apple is really funny. I mean, they say that this works:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch* touch = [touches any         


        
8条回答
  •  情深已故
    2020-12-05 15:18

    According to a similar question, your method should work.

    This leads me to think that your view's nextResponder is not actually the ViewController, as you suspect.

    I would add a quick NSLog in your forwarding code to check what your nextResponder really points to:

    if (numTaps < 2) {
        NSLog(@"nextResponder = %@", self.nextResponder);
        [self.nextResponder touchesBegan:touches withEvent:event];
    }
    

    You can also change your other NSLog messages so that they output type and address information:

    NSLog(@"touched %@", self);
    

    touched

    This should get you started on diagnosing the problem.

提交回复
热议问题