I\'m trying to find a way to consume a button press, not from the response chain per se, but from other action methods bound to that button. I\'ve looked all over for this
Based on the @danielquokka idea about override the method sendActionsForControlEvents:
, I subclass UIButton and add following codes. It works fine. After firing event, it will block UI events for 0.5 seconds.
- (void)sendAction:(SEL)action to:(id)target forEvent:(UIEvent *)event
{
[super sendAction:action to:target forEvent:event];
self.userInteractionEnabled = NO;
///! After handle UIEvent, block this button UI events for a while.
[self performSelector:@selector(delayEnable) withObject:nil afterDelay:0.5];
}
- (void)delayEnable
{
self.userInteractionEnabled = YES;
}
Another way to ignore UI events is by [[UIApplication sharedApplication] beginIgnoringInteractionEvents]
and [[UIApplication sharedApplication] endIgnoringInteractionEvents]
.
beginIgnoringInteractionEvents
and endIgnoringInteractionEvents
will block all touch events for the Application until endIgnoringInteractionEvents
called.