如何处理 iPhone 上的单点触摸和双点触摸

发布于 2024-09-29 20:23:59 字数 198 浏览 8 评论 0原文

我想做一些类似于 iPhone 的照片查看器的东西。单击时,UI 栏会在短暂延迟后消失。当您双击时,它会放大。但我不希望双击时发生任何事情,因为我还没有实现放大。

有人知道如何做到这一点吗?

[这篇文章]并没有真正帮助。除非你告诉我有必要子类化UIGestureRecognizer。然后,我想我可以弄清楚。有人有例子吗?

I want to do something similar to iPhone's photo viewer. When you single tap, the UI bars disappear after a short delay. When you double tap, it zooms in. But I don't want anything to happen on double tap because I haven't yet implemented zooming in.

Anyone know how to do this?

[This post] didn't really help. Unless you tell me it's necessary to subclass UIGestureRecognizer. Then, I think I could figure it out. Anyone have any examples?

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

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

发布评论

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

评论(3

霊感 2024-10-06 20:23:59

查看 UITapGestureRecognizer 文档。您需要查看两个属性:

  • numberOfTapsRequired;和
  • numberOfTouchesRequired

Look at the UITapGestureRecognizer documentation. There's two properties you want to look at:

  • numberOfTapsRequired; and
  • numberOfTouchesRequired
无法言说的痛 2024-10-06 20:23:59

查看 Three20 的 PhotoView。它会做你想要做的事情。

Check out Three20's PhotoView. It does what you're looking to do.

甜味拾荒者 2024-10-06 20:23:59

下面是一些应该有帮助的代码:

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
[scrollView addGestureRecognizer:singleTap];
[singleTap release];

UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
[doubleTap setNumberOfTapsRequired: 2];
[scrollView addGestureRecognizer:doubleTap];
// this next line will hold callbacks to singleTap until enough time has gone by that doubleTap is not a possibility.  If a doubleTap happens, singleTap will not get called. Otherwise, singleTap's callback gets called.
[singleTap requireGestureRecognizerToFail:doubleTap];
[doubleTap release];

Here's some code that should help:

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
[scrollView addGestureRecognizer:singleTap];
[singleTap release];

UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
[doubleTap setNumberOfTapsRequired: 2];
[scrollView addGestureRecognizer:doubleTap];
// this next line will hold callbacks to singleTap until enough time has gone by that doubleTap is not a possibility.  If a doubleTap happens, singleTap will not get called. Otherwise, singleTap's callback gets called.
[singleTap requireGestureRecognizerToFail:doubleTap];
[doubleTap release];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文