How can I detect a double tap on a certain cell in UITableView?
i.e. I want to perform one action if the user made a single touch and a
I chose to implement it by overriding the UITableViewCell.
MyTableViewCell.h
@interface MyTableViewCell : UITableViewCell
@property (nonatomic, assign) int numberOfClicks;
@end
MyTableViewCell.m
@implementation MyTableViewCell
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *aTouch = [touches anyObject];
self.numberOfClicks = [aTouch tapCount];
[super touchesEnded:touches withEvent:event];
}
TableViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
MyTableViewCell *myCell = (MyTableViewCell*) [self.tableView cellForRowAtIndexPath:indexPath];
NSLog(@"clicks:%d", myCell.numberOfClicks);
if (myCell.numberOfClicks == 2) {
NSLog(@"Double clicked");
}
}