gpt4 book ai didi

ios - 接收gestureRecognizer :shouldRecognizeSimultaneouslyWithGestureRecognizer when gestureRecognizerShouldBegin: returned NO

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:44:37 27 4
gpt4 key购买 nike

我有一个包含 UIPanGestureRecognizer 的 View 。同一个 View 还包含一个 UIScrollView

当用户在 ScrollView 上平移时,我在 gestureRecognizerShouldBegin: 中返回 NO,以确保 ScrollView 的手势识别器接管手势。

但是,我仍然收到 gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: 消息。很容易修复,我只需要在gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:中返回NO,但是我想知道在gestureRecognizerShouldBegin:中返回NO后是否正常收到这条消息.

代码

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
NSLog(@"gestureRecognizerShouldBegin:0x%x - return NO", (int)gestureRecognizer);
return NO;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
NSLog(@"gestureRecognizer:0x%x shouldRecognizeSimultaneouslyWithGestureRecognizer:0x%x", (int)gestureRecognizer, (int)otherGestureRecognizer);
return YES;
}

输出

2013-03-04 11:30:14.876 XXXX[99271:19d03] gestureRecognizerShouldBegin:0x9d6c380 - return NO
2013-03-04 11:30:14.876 XXXX[99271:19d03] gestureRecognizer:0x9d6c380 shouldRecognizeSimultaneouslyWithGestureRecognizer:0xbb75240

最佳答案

我认为这种行为是可以的。以下引用gestureRecognizerShouldBegin:官方文档讨论的方法:

This method is called when a gesture recognizer attempts to transition out of the UIGestureRecognizerStatePossible state. Returning NO causes the gesture recognizer to transition to the UIGestureRecognizerStateFailed state.

这清楚地表明它不会阻止手势识别器,但会转换到相应手势识别器的 UIGestureRecognizerStateFailed 状态。因此其他委托(delegate)方法将被正常调用。

关于ios - 接收gestureRecognizer :shouldRecognizeSimultaneouslyWithGestureRecognizer when gestureRecognizerShouldBegin: returned NO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15206311/

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