Consider the following code:
@interface TouchDownGestureRecognizer : UIGestureRecognizer
@end
@implementation TouchDownGestureRecognizer
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesBegan");
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesMoved");
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesEnded");
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"touchesCancelled");
}
@end
In the constructor for a class that derives from UIView
- (id)initWithFrame:(CGRect)frame
{
<snip>
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
[tapRecognizer setDelegate:self];
[self addGestureRecognizer:tapRecognizer];
TouchDownGestureRecognizer *touchDownRecognizer = [[TouchDownGestureRecognizer alloc] initWithTarget:self action:@selector(handleTouchDown:)];
[self addGestureRecognizer:touchDownRecognizer];
<snip>
}
An object of this class is added to a parent view, and for the most part, tapping the subview causes touchesBegan, touchesEnded, and handleTap to get called. Under some circumstance (which I have not been able to pinpoint), handleTap stops getting called for the subview, (and the parent's handleTap gets called instead). However, even though handleTap stops getting called, touchesBegan and touchedEnded continue to get called for the subview. I have ensured that the UITapGestureRecognizer is still in the subview's gestureRecognizers array. I have also ensured that the userInteractionEnabled property for the subview is YES. Is there some known condition or state of the UIView where we would expect this behavior?