Note: please see the comments below to see though while this solution worked for me, it still may not be a good idea.
An alternative to creating a subclass of UITableView
or UITableViewCell
(and to using a timer) would be just to extend the UITableViewCell
class with a category, for example (using @oxigen's answer, in this case for the cell instead of the table):
@implementation UITableViewCell (DoubleTap)
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if(((UITouch *)[touches anyObject]).tapCount == 2)
{
NSLog(@"DOUBLE TOUCH");
}
[super touchesEnded:touches withEvent:event];
}
@end
This way you don't have to go around renaming existing instances of UITableViewCell
with the new class name (will extend all instances of the class).
Note that now super
in this case (this being a category) doesn't refer to UITableView
but to its super, UITView
. But the actual method call to touchesEnded:withEvent:
is in UIResponder
(of which both UITView
and UITableViewCell
are subclasses), so there's no difference there.