Search code examples
iosforwardingios5touch-event

UIButton Touch Forwarding Not Working In iOS5 (only on iPad)


I can't seem to be able to figure out why this code for forwarding a UIButton touch stopped working in iOS5:

- (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];
}

When I log the next responder's touches methods I can see that touches moved is only forwarded once and touches ended isn't forward at all. This is very unexpected behavior, as all touches are forwarded in iOS4. Any help would be appreciated.


Solution

  • While comment posters were able to get this code to work fine in their tests, I was unsuccessful in getting it to reliably work in iOS5. My solution was to use delegation to forward the touches to the interested party. Not elegant or preferred, but so far has worked fine without any gotchas.