我想做类似iPhone的照片浏览器。单击时,UI栏会在短暂延迟后消失。双击时,它会放大。但我不想在双击时发生任何事情,因为我还没有实现放大。
任何人都知道怎么做?
[这篇文章]并没有真正帮助。除非你告诉我有必要继承UIGestureRecognizer
。然后,我想我可以搞清楚。有人有任何例子吗?
答案 0 :(得分:2)
查看UITapGestureRecognizer
文档。您想要查看两个属性:
numberOfTapsRequired
;和numberOfTouchesRequired
答案 1 :(得分:0)
查看Three20的PhotoView。它会做你想做的事。
答案 2 :(得分:0)
以下是一些应该有用的代码:
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];