ios - 从 UITapGestureRecognizer 中删除目标

标签 ios xamarin xamarin.ios uigesturerecognizer target-action

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

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

如何删除目标?需要 UIGestureRecognizer.Token

最佳答案

RTFM这里是正确的:

An instance of this class is returned when you invoke the UIGestureRecognizer's UIGestureRecognizer.AddTarget method. The AddTarget returns this token as a mechanism for later unsubscribing this particular action from the recognizer using the UIGestureRecognizer.RemoveTarget method.

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

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

关于ios - 从 UITapGestureRecognizer 中删除目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32115108/

相关文章:

ios - iOS 应用程序的背景在测试时未加载

添加披露指示器时 ios8 单元格约束中断

objective-c - 以编程方式创建 View

c# - MvvmCross 自定义绑定(bind)通过 INotifyPropertyChanged

c# - 如何在 Monotouch 中使用 iOS RespondsToSelector?

ios - 来自 Azure 通知中心的 Xamarin.iOS 推送通知

iphone - 带 MonoTouch 的 XCode 4 界面生成器

ios - 有什么方法可以使用星期几的谓词来过滤日期数组吗?

xamarin - 如何更改导航页面中后退箭头和后退文本的字体大小和粗细?

ios - Monotouch iOS - 从函数执行Segue