That sounds great but I want to be able to send the event and the touch to the singleTap method since this will forward it if necessary to another responder. I cannot do this with this solution.
I have tried using a timer but there seems to be a problem. Can anybody tell me what might be wrong.
In my touchesBegan method I did
Code:
if ([doubleTapTimer isValid]) {
[doubleTapTimer invalidate];
doubleTapTimer = nil;
}
if(![doubleTapTimer isValid]) {
[self startTouchTimer:DOUBLE_TAP_TIMER withTouch:touches andEvent:event];
} else if (tapCount == 2) {
if(self.zoomedView) {
[self resetScrollZoom];
} else {
[super touchesBegan:touches withEvent:event];
}
[doubleTapTimer invalidate];
doubleTapTimer = nil;
return;
}
Then in my startTouchTimer method I prepare my timer with an invocation to call the singleTapMethod.
Code:
//Prepare invocation
SEL singleTapSelector = @selector(singleTapDone:withEvent:); //selector
NSMethodSignature * sig = [[self class] instanceMethodSignatureForSelector:singleTapSelector]; //signature to initialize
NSInvocation *singleTapObjects = [NSInvocation invocationWithMethodSignature:sig]; //initialize selector
[singleTapObjects setTarget:self];
[singleTapObjects setSelector:singleTapSelector];
[singleTapObjects setArgument:&touches atIndex:2]; //set parameters for invocations
[singleTapObjects setArgument:&event atIndex:3];
doubleTapTimer = [NSTimer scheduledTimerWithTimeInterval:delay invocation:singleTapObjects repeats:NO];
This successfully calls the singleTapMethod and when looking at the debugger the objects passed are the same (location wise) but when calling [super touchesBegan:withEvent] on this method it does not handle it at all. Nothing happens. If I just implement the [super touchesBegan:withEvent] on the touchesBegan method it successfully handles it by forwarding it.
BTW already tried using self.nextResponder to try and force it myself to forward the touchesBegan but it won't work either.
Edit:
I did some more research and although the touch and event do get forwarded, when getting to the touchesBegan on the subview they have been forwarded to the reason they don't work is because getting the coordinates and/or the tapCount returns cero for the touch. Can anybody please shed some light on this situations?