gpt4 book ai didi

objective-c - 使用 gestureRecognizer :shouldRecognizeSimultaneouslyWithGestureRecognizer: 时两个手势识别器之间的顺序

转载 作者:太空狗 更新时间:2023-10-30 03:55:21 39 4
gpt4 key购买 nike

我有一个 UIScrollView,我向它添加了一个 UIPanGestureRecognizer

我想同时使用 scrollView.panGestureRecognizer(默认)和我的自定义识别器。

所以我将函数 gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: 重写为 YES,并且我同时调用了 panGestureRecognizer

我的问题是我需要先调用自定义识别器,然后再调用默认识别器。

在文档中,我读到:

In the default behavior, touch events in a multitouch sequence go from one gesture recognizer to another in a nondeterministic order until the events are finally delivered to the view (if at all).

有没有办法让两个识别器都以确定性顺序激活?

最佳答案

您是否尝试过使用:

- (void)requireGestureRecognizerToFail:(UIGestureRecognizer *)otherGestureRecognizer

您可以在 UIScrollView 平移手势识别器上调用它,以确保首先调用您的自定义识别器。

关于objective-c - 使用 gestureRecognizer :shouldRecognizeSimultaneouslyWithGestureRecognizer: 时两个手势识别器之间的顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13161879/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com