如何处理iPhone的单件与双触摸
-
28-09-2019 - |
题
我想做类似于iPhone的照片查看器的事情。当您单击时,UI棒在短时间后消失了。双击时,它会放大。但是我不希望Double Tap上发生任何事情,因为我尚未实现放大。
有人知道怎么做吗?
这篇文章]并没有真正的帮助。除非你告诉我有必要子类 UIGestureRecognizer
. 。然后,我想我可以弄清楚。有人有例子吗?
解决方案
看着那(这 UITapGestureRecognizer
文档。您想查看两个属性:
numberOfTapsRequired
;和numberOfTouchesRequired
其他提示
查看320的光盘。它可以做您想做的事情。
这是一些应有帮助的代码:
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];
不隶属于 StackOverflow