When a drag gesture conflicts with a sweep gesture (when UIPanGestureRecognizer conflicts with UISwipeGestureRecognizer), pangesturerecognizer

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.