iOS 13 UIPanGestureRecognizer的行为与iOS 12不同

时间:2019-07-06 23:45:45

标签: ios cocoa-touch uigesturerecognizer uipangesturerecognizer

我有一个自定义滚动视图,该视图在使用UIPanGestureRecognizer的iOS 13之前运行良好:

    _panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
    _panRecognizer.delegate = self;

- (void)handlePan:(UIGestureRecognizer *)gestureRecognizer
{
    UIPanGestureRecognizer* pgr = (UIPanGestureRecognizer*)gestureRecognizer;
    if (pgr.state == UIGestureRecognizerStateChanged) {
        // do something
    }
}

现在,它在iOS 13上无法正常运行。handlePan函数在三根手指一起平移之前不再被调用。在iOS 12中,仅移动一根手指即可调用此功能。

我尝试设置min/maximumNumberOfTouches,但不起作用。有什么变化吗?

1 个答案:

答案 0 :(得分:1)

听起来您的手势现在正在与系统手势竞争。您是否检查了视图的.gestureRecognizers属性以查看是否有所更改?

您可能必须实现gestureRecognizer(_:shouldRecognizeSimultaneouslyWith:)委托方法,默认情况下它返回false。