我已将动作作为匿名方法添加到手势识别器中

UITapGestureRecognizer tapGesture = new UITapGestureRecognizer ();
tapGesture.AddTarget (() => HandleTap (tapGesture));

如何删除目标? UIGestureRecognizer.Token是必需的。

最佳答案

RTFM在这里是正确的:

调用UIGestureRecognizer的UIGestureRecognizer.AddTarget方法时,将返回此类的实例。 AddTarget返回此 token ,作为以后使用UIGestureRecognizer.RemoveTarget方法从识别器取消订阅此特定操作的机制。

UIGestureRecognizer.Token token = tapGesture.AddTarget (() => HandleTap (tapGesture));

if (token != null) {
    tapGesture.RemoveTarget (token);
}

10-07 22:47