0

I'm trying to implement a UIResponder object that will allow me to record screen activity, then pass the event on to the next responder to allow the application to proceed as normal. I've been researching this for a while now and see two ways that should work: Either create a root view and ignore touches in the subviews placed on top of it, allowing the root view to handle them; OR create a GestureRecognizer which is added to all the subviews. My application has multiple views that are swapped in and out on the main window.

I've tried both methods and end up at the same impasse: I get the touchesBegan/touchesMoved/touchesEnded events in my view (or Recognizer), but nothing happens when I send them down the responder chain. I've tried all of the following. Note that 'view' is derived from touch.view and view.superview is my 'loginView' object, which contains the button that was tapped to get me here:

 [view hitTest:frame.origin withEvent:event];
 [view touchesBegan:touches withEvent:event];
 [view.superview hitTest:frame.origin withEvent:event];
 [view.superview touchesBegan:touches withEvent:event];
 [[view nextResponder] touchesBegan:touches withEvent:event];
 [[view nextResponder] hitTest:frame.origin withEvent:event];
 [[[view superview] nextResponder] touchesBegan:touches withEvent:event];
 [[view superview] hitTest:frame.origin withEvent:event];

None of these work, and in fact '[[view nextResponder] hitTest...' generates a warning.

I've tried resignFirstResponder, and was even going to try a sendAction, but I'm just grasping at straws at this point. I've tried putting my view at both the bottom and top of the chain and get the same results. Obviously I'm missing something, but I can't see what.

Can anyone give me a clue as to what to try next?

-- Sam

1 Answers1

0

I'm not really sure what exactly you're a trying to do, but maybe http://iphonedevelopment.blogspot.com/2008/10/bit-about-responder-chain.html helps you.

Personally, what I'm doing in a UIView subclass to pass the touches around is this:

- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent *)event {
    [super touchesBegan:touches withEvent:event];
    [[self nextResponder] touchesBegan:touches withEvent:event];
}

- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent *)event {
    [super touchesMoved:touches withEvent:event];
    [[self nextResponder] touchesMoved:touches withEvent:event];
}

- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent *)event {
    [super touchesEnded:touches withEvent:event];
    [[self nextResponder] touchesEnded:touches withEvent:event];
}
Sascha
  • 5,903
  • 3
  • 24
  • 20
  • Thanks, but that's what I've tried, and it still doesn't work for me. The event is never passed on to the nextResponder. All the examples make it look like mine should work, but it doesn't. Does the fact that my underlying view is tied to IBActions and Outlets have anything to do with it? I am intercepting a button press and trying to make the underlying view's button react; It does not. I "consume" the touchesBegan event (even though I don't want to), and it goes no further. – YosemiteSam Jun 01 '11 at 18:58
  • OK, I'm getting a little closer: I have determined that sending touchesBegan to a UIButton object does not seem to cause it to fire the UIControlEventTouchUpInside event. If that event doesn't fire, the callback associated with the button doesn't fire. So for every object in my app I want to monitor I need to call the appropriate "fire" event? That seems klunky. – YosemiteSam Jun 02 '11 at 17:23