在我的游戏中保持 Touches 延迟? UIGestureEnvironmentSortAndSendDelayedTouches?

held Touches are delayed in my game? UIGestureEnvironmentSortAndSendDelayedTouches?

我在应用程序商店中有一个 iOS cocos2d (v2) 游戏,我已经多年没有更新了,但最近发现了一个错误并需要修复它。这需要我经历让应用程序构建在 XCode 的现代版本上的所有痛苦。在一切正常并准备好将我的补丁提交到应用程序商店后,我意识到当我的应用程序实际检测到用户触摸并保持在屏幕上的位置时,现在有一个非常慢的时间滞后。

在查看调用堆栈时,如果我快速点击屏幕,一切正常,我的断点也很快被触发:

但是如果我触摸并按住屏幕,在我的断点被击中之前几乎有一秒钟的延迟,调用堆栈如下所示:

我的问题是,如何关闭此行为,以免延迟触摸或调用 UIGestureEnvironmentSortAndSendDelayedTouches?换句话说,我需要触摸并按住屏幕才能立即触发事件,与快速点击时完全一样。

更新

这是完整的堆栈跟踪:

 * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
     frame #0: 0x0000000100e79ab0 mygame`-[CCGLView touchesBegan:withEvent:](self=0x0000000102029c40, _cmd="touchesBegan:withEvent:", touches=0x0000000282f373c0, event=0x0000000281d62e20) at CCGLView.m:331
     frame #1: 0x00000001ca6aeaf0 UIKitCore`_UIGestureEnvironmentSortAndSendDelayedTouches + 4324
     frame #2: 0x00000001ca6a97ec UIKitCore`_UIGestureEnvironmentUpdate + 1236
     frame #3: 0x000000019d8896bc CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
     frame #4: 0x000000019d884350 CoreFoundation`__CFRunLoopDoObservers + 412
     frame #5: 0x000000019d8848f0 CoreFoundation`__CFRunLoopRun + 1264
     frame #6: 0x000000019d8840e0 CoreFoundation`CFRunLoopRunSpecific + 436
     frame #7: 0x000000019fafd584 GraphicsServices`GSEventRunModal + 100
   * frame #8: 0x00000001caa98c00 UIKitCore`UIApplicationMain + 212
     frame #9: 0x0000000100c7f8a4 mygame`main(argc=1, argv=0x000000016f2c77d8) at main.m:5
     frame #10: 0x000000019d342bb4 libdyld.dylib`start + 4

原来我能解决这个问题的最好方法是设置 window 的 UIGestureRecognizer 实例的委托:

  # in app delegate: 
  CGRect frame = [[UIScreen mainScreen] bounds];
  UIWindow *window = [[UIWindow alloc] initWithFrame:frame];
  for (UIGestureRecognizer *gestureRecognizer in [window gestureRecognizers]) {
    gestureRecognizer.delegate = self;
  }

然后在该委托上实现以下方法:

-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    return NO;
}

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
    return NO;
}

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceivePress:(UIPress *)press {
    return NO;
}