gpt4 book ai didi

ios - 从 UITapGestureRecognizer 中删除目标

转载 作者:行者123 更新时间:2023-12-01 19:55:02 24 4
gpt4 key购买 nike

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

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/

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