Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gestures Conflict on UITableView swipe to delete iOS

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.

like image 504
Alvin John Tandoc Avatar asked Dec 26 '22 05:12

Alvin John Tandoc


1 Answers

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;

}

like image 66
Kamen Dobrev Avatar answered Feb 01 '23 11:02

Kamen Dobrev