在 UITableView 单元格上处理平移手势

Handle Pan Gesture on UITableView cell

我将 MARKRangeSlider 添加到 UITableViewCell 并且它按预期工作。拖动手柄时,table 视图控制器也会弹出到前一个视图控制器。如何避免或阻止弹出的动作?

我尝试通过添加委托来执行以下代码,但未能实现结果。

 - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
         // CGPoint velocity = [panGestureRecognizer  velocityInView:panGestureRecognizer.view];
         // return fabs(velocity.y) > fabs(velocity.x);
        CGPoint translation = [(UIPanGestureRecognizer *)gestureRecognizer translationInView:gestureRecognizer.view.superview];
        // if you want an NSString
        NSLog(@"gestureRecognizer-superview %@", NSStringFromClass([gestureRecognizer.view.superview class]) );
        return fabs(translation.x) > fabs(translation.y);
    }


- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
    if (otherGestureRecognizer == leftPanRecognizer) {
        return YES;
    }
    if (otherGestureRecognizer == rightPanRecognizer) {
        return YES;
    }
    return NO;
}

它的间歇性问题。请告诉我如何处理?

提前致谢

我找到了解决方案,

UITableViewControllerUIViewController 中有 UITableView 必须 禁用 interactivePopGestureRecognizerviewDidAppearsame 控制器开发人员必须 enable interactivePopGestureRecognizer in viewWillDisAppear 。希望对你有帮助。