There is probably a better answer, but here is one way to do this:
First, create a long click gesture recognizer on the table view itself.
UILongPressGestureRecognizer* longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onLongPress:)]; [self.tableView addGestureRecognizer:longPressRecognizer];
Then process it using a procedure that can find the selected row:
-(void)onLongPress:(UILongPressGestureRecognizer*)pGesture { if (pGesture.state == UIGestureRecognizerStateRecognized) { //Do something to tell the user! } if (pGesture.state == UIGestureRecognizerStateEnded) { UITableView* tableView = (UITableView*)self.view; CGPoint touchPoint = [pGesture locationInView:self.view]; NSIndexPath* row = [tableView indexPathForRowAtPoint:touchPoint]; if (row != nil) { //Handle the long press on row } } }
I have not tried, but I think that you could keep the line in the selection display, forcing the gesture recognizers in the table view to wait until a long press is obtained.
Prof Von Lemongargle
source share