UIGestureRecognizer 在 targetView 外部触摸时取消

发布于 2025-01-06 02:14:34 字数 216 浏览 0 评论 0原文

我有一个 UIView,我想知道用户何时执行操作:

touchDownInside (突出显示视图)

touchUpInside (确认操作)

touchUpOutside code> (取消并重置突出显示)

什么gestureRecognizer可以为我做这个?

I have a UIView of which I want to know when the user is doing:

touchDownInside (to highlight the view)

touchUpInside (to confirm the action)

touchUpOutside (to cancel and reset the hightlight)

what gestureRecognizer can do this for me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盛夏已如深秋| 2025-01-13 02:14:34

请仔细阅读您的视图也可以重写的四种方法,以处理四种不同的触摸事件:

1)手指触摸屏幕

-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event;

2)手指在屏幕上移动(当手指移动时会重复此消息。)

-(void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event;

3)手指或者手指从屏幕上移开

-(void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event;

4) 系统事件,在触摸结束之前中断触摸

-(void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event;

Please go though these four methods also which your view can override to handle the four distinct touch events:

1) finger or fingers touches the screen

-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event;

2)finger or fingers move across the screens(this message repeatedly as a finger moves.)

-(void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event;

3)finger or fingers is removed from the screen

-(void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event;

4) a system event,interrupts a touch before it ends

-(void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event;
任性一次 2025-01-13 02:14:34

您可以通过实现触摸方法本身来做到这一点,为什么需要手势识别器?

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 

上述函数为着陆。

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

以上功能用于润色。以及两者的组合用于取消。

You can do this implementing the touches methods itself, why do you need gesture recognizer?

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 

The above function for touch down.

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

The above function for touch up. And the combination of both for cancel.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文