How to pause / disable UILongPressGestureRecognizer in UITableViewCell while editing

In the table view, I have each cell a UILongPressGestureRecognizer

, which I add like so:

UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] 
                                          initWithTarget:self 
                                          action:@selector(TableCellLongPressed:)];
longPress.minimumPressDuration = 0.5f;
[cell addGestureRecognizer:longPress];
[longPress release];

      

Now I have the following problem, I want the user to be able to change a cell in the table view, so I have a button that sets the tableView to EditMode like this:

[self.myTableView setEditing:!self.myTableView.editing animated:YES];

      

Now, when the user tries to drag the cell and doesn't drag it far enough, longPress triggers its action, which is very annoying for the user, causing another click. How to pause or disable UILongPressGestureRecognizer

when tableView is in EditMode?

+3


source to share


1 answer


This method requires the UIGestureRecognizerDelegate delegate to be implemented:

gestureRecognizer: shouldReceiveTouch:



In this method, check if you are editing the table and return NO if you are.

Tim

+4


source







All Articles