UITapGestureRecognizer 无法在 iOS9 上工作

Lir*_*ron 5 xcode uigesturerecognizer ios ios9 xcode7

我有一个应用程序,UITapGestureRecognizers它似乎在 iOS9 Beta 2 中不起作用。

他们正在成功调用

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
  NSLog(@"shouldReceiveTouch");
  return YES;
}
Run Code Online (Sandbox Code Playgroud)

但它不会影响任何其他 UITapGesture 委托方法。

当我在运行 iOS 8 的设备上运行相同的应用程序(来自 Xcode 7)时,它按预期工作。

还有其他人打过这个吗?

以下是我初始化 UITapGestureRecognizer 的方法。 点击手势识别器设置

编辑
如果我在代码中而不是在 ViewController xib 中创建 UITapGestureRecognizer 它工作正常,因此 iOS9 中的 xib 解析或其他内容出现了问题。

_tapGesture2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onMainViewTap:)];
_tapGesture2.numberOfTapsRequired = 1;
_tapGesture2.delegate = self;
[self.view addGestureRecognizer:_tapGesture2];
Run Code Online (Sandbox Code Playgroud)

Edit2
如果我删除了 XIB 中的 GestureRecognizer 并使用 XCode 7 再次将其添加回来,它也可以工作。当我这样做时,它添加<pressTypeMask key="allowedPressTypes"/>到了 UITapGestureRecognizer 下的 xib 中。

Lir*_*ron 3

看起来 iOS9<pressTypeMask key="allowedPressTypes"/>在手势识别器的 xml 中查找一行,如果没有它,点击识别器就无法工作。要解决此问题,您可以在代码中构建识别器,将该行添加到 xml 中,或者删除并重新添加 Xcode 7 中的手势识别器,这将正确地将其添加pressTypeMask到 xml 中。

我想知道苹果是否会修复 iOS9,使其在 XML 中没有该行的情况下工作,但就目前而言,这是一个简单的修复。

  • 将此作为错误报告给 Apple。 (2认同)