如何判断子视图是否被点击两次

发布于 2024-08-15 01:05:11 字数 111 浏览 2 评论 0原文

我有一个在 UIView 内部分配的 UIImageView。我想使用 TOUCCHESENDED 或 TOUCCHESBEGAN 双击该子视图并发送回调或至少发送日志。我将不胜感激任何可以上传一些代码的人。

I have a UIImageView that I allocated inside of a UIView. I want to double tap that subview using the TOUCHESENDED or TOUCHESBEGAN and send a callback or at least a log. I would appreciate anyone who can upload some code.

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

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

发布评论

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

评论(2

柠檬心 2024-08-22 01:05:11

以下是如何在 touchesBegan 中使用 .tapCount 属性:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
{
    NSUInteger numTaps = [[touches anyObject] tapCount];
    UITouch *touch = [[event allTouches] anyObject];

    if ([touch view] == yourThing) {
            NSLog(@"%i taps", numTaps);
    }
}

Here's how to use the .tapCount property inside touchesBegan:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
{
    NSUInteger numTaps = [[touches anyObject] tapCount];
    UITouch *touch = [[event allTouches] anyObject];

    if ([touch view] == yourThing) {
            NSLog(@"%i taps", numTaps);
    }
}
潦草背影 2024-08-22 01:05:11

根据文档,不建议子类化UIImageView,但这是为了绘图,如果您只想捕获事件,您可以子类化UIImageVIew并捕获事件。然后查看触摸的 tapCount 属性。根据 http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UITouch_Class/Reference/Reference.html#//apple_ref/occ/instp/UITouch/tapCount

As per the documentation, it is not recommended to subclass UIImageView, but this is for drawing, if you only want to catch events, you may subclass UIImageVIewand catch the event. Then look at the tapCount property of the touch. As per http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UITouch_Class/Reference/Reference.html#//apple_ref/occ/instp/UITouch/tapCount

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