When a drag gesture conflicts with a sweep gesture (when UIPanGestureRecognizer conflicts with UISwipeGestureRecognizer), pangesturerecognizer
The story occurs in this situation: Add a drag gesture to the entire controller, and then add a left slide cleaning gesture to each Cell on the control. Then the problem arises: only the drag gesture works, but the left slide gesture does not. How can this problem be solved! First:
When a drag gesture (UIPanGestureRecognizer) is added to the entire controller, the left slide cleaning gesture (UISwipeGestureRecognizer) is added to the UITableViewCell In the controller, cell's left slide gesture is no longer available!
The solution is to set a priority for the two gestures.: [PanGes requireGestureRecognizerToFail: cell. leftSwipe];
Key code
1 + (instancetype) cellWithTableView :( UITableView *) tableView {2 static NSString * reuseIdentity = @ "tanCell"; 3 4 TanTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: reuseIdentity]; 5 6 if (cell = nil) {7 cell = [[TanTableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: reuseIdentity]; 8 9 // set the gesture priority, avoid gesture conflict 10 UIPanGestureRecognizer * panGes = [tableView. superview. gestureRecognizers objectAtIndex: 0]; 11 [panGes requireGestureRecognizerToFail: cell. leftSwipe]; 12 [panGes requireGestureRecognizerToFail: cell. rightSwipe]; 13} 14 return cell; 15}
For how to set the left-sliding multi-menu function gesture for the Cell, see article: Customize UITableViewCell to implement left-sliding multi-menu function LeftSwipe
Download DEMO:
Github: https://github.com/xiaotanit/Tan_SwipeAndPan
Link: http://www.cnblogs.com/tandaxia/p/5349090.html