iOS 13 UIPanGestureRecognizer的行为与iOS 12不同 [英] iOS 13 UIPanGestureRecognizer behave differently from iOS 12

查看:39
本文介绍了iOS 13 UIPanGestureRecognizer的行为与iOS 12不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a custom scroll view that works well before iOS 13 that uses UIPanGestureRecognizer:

    _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中,仅移动一根手指即可调用此功能.

Now it didn't work well with iOS 13. The handlePan function does not get called anymore until 3 fingers are panning together. In iOS 12, this function will be called when just 1 finger is moved.

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

I have tried setting the min/maximumNumberOfTouches but not working. Is there anything changed?

推荐答案

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

It sounds like your gesture is now competing with a system gesture. Did you check the .gestureRecognizers property of the view to see if something changed?

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

You might have to implement gestureRecognizer(_:shouldRecognizeSimultaneouslyWith:) delegate method, by default it returns false.

这篇关于iOS 13 UIPanGestureRecognizer的行为与iOS 12不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆