Then why don't you use UIGestures with the TableView.This will be the easiest solution which worked for me like charm.
Here is the code which will help you to implement it in your code :
// Put this code in your ViewDidLoad:
UITapGestureRecognizer *doublegesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTableViewCellDoubleTapping:)];
doublegesture.numberOfTapsRequired = 2;
[roomTableView addGestureRecognizer:doublegesture];
[doublegesture release];
//Method to handle the event on double tapping
-(void)didTableViewCellDoubleTapping:(UITapGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
CGPoint swipeLocation = [gestureRecognizer locationInView:roomTableView];
NSIndexPath *swipedIndexPath = [roomTableView indexPathForRowAtPoint:swipeLocation];
NSLog(@"%d",swipedIndexPath.row);
// ... Here you can add your logic
}
}
In the similar way, if you add another UIGesture for Single tapping
UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTableViewSingleCellTapping:)];
gesture.numberOfTapsRequired = 1;
[roomTableView addGestureRecognizer:gesture];
[gesture release];
[gesture requireGestureRecognizerToFail:doublegesture];
-(void)didTableViewSingleCellTapping:(UITapGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
CGPoint swipeLocation = [gestureRecognizer locationInView:roomTableView];
NSIndexPath *swipedIndexPath = [roomTableView indexPathForRowAtPoint:swipeLocation];
NSLog(@"%d",swipedIndexPath.row);
}
}