只允许某个 UIGestureRecognizer 立即执行

发布于 2024-12-23 16:10:45 字数 436 浏览 1 评论 0 原文

我想防止 UIGestureRecognizers 同时工作,所以我实现了下面的方法。但是,我只想允许 otherGestureRecognizer 在gestureRecognizer尝试同时识别时自行工作。

请你告诉我如何才能实现这一目标?

顺便说一句,这是为了防止在 tableView 处于“删除模式”时视图向下平移(拖动)。

- (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    gestureRecognizer.enabled = NO;
    return NO;
}

I want to prevent UIGestureRecognizers working simultaneously, so I implemented the method below. However, I would only like to allow the otherGestureRecognizer to work on it's own while the gestureRecognizer is attempting to recognise simultaneously.

Please can you tell me how I can achieve that?

Btw, this is to prevent the view from panning (dragging) down while the tableView is in 'deletion mode'.

- (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    gestureRecognizer.enabled = NO;
    return NO;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凡间太子 2024-12-30 16:10:45

您的问题有点不清楚,但我认为您可能正在寻找:

- (void)requireGestureRecognizerToFail:(UIGestureRecognizer *)otherGestureRecognizer

来自 UIGestureRecognizer 文档

此方法创建与另一个手势识别器的关系,延迟接收器从 UIGestureRecognizerStatePossible 的转换。接收器转换到的状态取决于 otherGestureRecognizer 发生的情况:

Your question is a bit unclear but I think you might be looking for:

- (void)requireGestureRecognizerToFail:(UIGestureRecognizer *)otherGestureRecognizer

From the UIGestureRecognizer docs

This method creates a relationship with another gesture recognizer that delays the receiver’s transition out of UIGestureRecognizerStatePossible. The state that the receiver transitions to depends on what happens with otherGestureRecognizer:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文