我的手势识别器有问题。我的目标是在我的表 View 中使用滑动来删除。但我认为其他手势是相互冲突的。我正在使用这个库 romaonthego/REFrostedViewController 这是我的汉堡菜单库,这个库有一个 pangesture 功能。我认为冲突在于手势。因为当我在另一个项目中运行我的 tableview 代码时,它正在工作。请帮忙,提前谢谢你。

最佳答案

我有一个类似的问题,我最终做的是类似于 TonyMkenu ,但你需要允许更多的识别器:

- (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;

}

10-07 19:56
查看更多