I have a problem in my gesture recognizers. My goal is to implement using swipe to delete in my table view. But I think other gestures are conflicting with each other. I'm using this libray romaonthego/REFrostedViewController this a library for my hamburger menu and this library has a pangesture feature. I think the conflict is w/in the gestures. because when I run my code of my tableview in another project it's working.Pls help, Thank you in advance.
Asked
Active
Viewed 7,559 times
4
-
I think… you must disable "panGestureEnabled” and present the “menu" manually [self.frostedViewController presentMenuViewController]; – TonyMkenu Aug 27 '14 at 11:49
-
But I also need the pan gesture. I disabled the pan gesture but It's not working at all. I saw some applications used pan gestures on there menu and gesture to delete tha data in a table. I want to know how did they managed two run 2 pan gestures. T_T – Alvin John Tandoc Aug 27 '14 at 11:53
-
but.. what conflict do you have? You can't present the menu… or you can’t swipe the cell? – TonyMkenu Aug 27 '14 at 12:54
-
I can't swipe the cell. – Alvin John Tandoc Aug 27 '14 at 13:03
-
Hey buddy how did you solve this problem? – Viraj Padsala Feb 27 '17 at 08:56
4 Answers
4
I had a similar problem, what I ended up doing is similar to TonyMkenu , but there are more recognizers that you need to allow:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
if (otherGestureRecognizer.delegate == self )
return NO;
//if otherGestureRecognizer is swipe to delete from a UITableView cancel slide menu recognizers
if ([[otherGestureRecognizer.view class] isSubclassOfClass:[UITableView class]])
{
NSLog(@"Allow1 %@", [otherGestureRecognizer description]);
return YES;
}
if( [[otherGestureRecognizer.view class] isSubclassOfClass:[UITableViewCell class]] ||
[NSStringFromClass([otherGestureRecognizer.view class]) isEqualToString:@"UITableViewCellScrollView"] ||
[NSStringFromClass([otherGestureRecognizer.view class]) isEqualToString:@"UITableViewWrapperView"])
{
NSLog(@"Allow&Disable %@", [otherGestureRecognizer description]);
if(gestureRecognizer.delegate == self)
{//cancel the slide menu recognizer
gestureRecognizer.enabled = NO;
gestureRecognizer.enabled = YES;
}
return YES;
}
NSLog(@"Deny %@", [otherGestureRecognizer description]);
return NO;
}

Kamen Dobrev
- 1,321
- 15
- 20
4
Edit: Updated for iOS 11
The other answers were helpful, but in my case the best solution was to do the logic in shouldRequireFailureOfOtherGesture
like so:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
if (gestureRecognizer == self.pan) {
return YES;
}
return NO;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
if (gestureRecognizer == self.pan) {
// iOS 10
if ([NSStringFromClass([otherGestureRecognizer.view class]) isEqualToString:@"UITableViewWrapperView"]) {
return YES;
}
// iOS 11
else if ([otherGestureRecognizer isMemberOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer.view isKindOfClass:[UITableView class]]) {
return YES;
}
}
return NO;
}
This had a much better behavior in my case. I also used delaysTouchesBegan = YES
on my pan gesture. Might be useful!

beebcon
- 6,893
- 5
- 25
- 27
-
UITableViewWrapperView is not used in iOS 11. Anyone got this to work in iOS 11? – thejaz Oct 21 '17 at 14:12
-
-
2
In iOS 11,hope this can help you.
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
if ([[otherGestureRecognizer.view class] isSubclassOfClass:[UITableView class]]) {
if ([otherGestureRecognizer isKindOfClass: [UIPanGestureRecognizer class]]) {
UIPanGestureRecognizer *otherPan = (UIPanGestureRecognizer *)otherGestureRecognizer;
CGPoint translation = [otherPan translationInView:otherGestureRecognizer.view];
return translation.x < 0;
}
}
return NO;
}

Calabash Ball
- 23
- 4
0
First of all... check if you have this
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
and second...
try to add this
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
if ([gestureRecognizer.view isKindOfClass:[UITableView class]]) {
return YES;
} else {
return NO;
}
}
-
-
Sorry for the late reply, I already solve my problem by putting a reference to the gesture of my hamburger menu. Thank you for your answer :) – Alvin John Tandoc Oct 09 '14 at 01:44
-
@AlvinJohnTandoc I am facing similar problem in my current project. I assume that solution provided by TonyMkenu worked for you. If my assumption is correct, can you please tell me where to put the code (function provided in the answer)? Right now my code doesn't use these function anywhere. So should I put it in menu classes or in my own view controller classes? – Dipak Mishra May 29 '15 at 12:47