문제

In a tableview I have on every cell a UILongPressGestureRecognizer which I add like this:

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

Now I do have the following problem I want the user to be able to rearrange the cell in the tableview 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 a cell and does not drag it far enough the longPress fires his action which is very annoying for the user cause another view gets pushed. How can I pause or disable the UILongPressGestureRecognizer when the tableView is in EditMode?

도움이 되었습니까?

해결책

You should implement the UIGestureRecognizerDelegate delegate for this method:

gestureRecognizer:shouldReceiveTouch:

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

Tim

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top