开发者

iPhone count finger taps and time between taps

I'm pretty new to iPhone programming, so I'm looking for any pointers (no pun intended), links, search terms, etc. on how to make a very simple app that counts how many times one finger touches the screen and how long between each 开发者_StackOverflowtap.

Thanks for any help, I know this resembles a lame question seeing as how I have really accomplished anything yet.

rd42


In touchesBegan, use:

NSSet *allTouches = [event allTouches];
int tapCount = [allTouches count];

to retrieve the tap count.

You would then need to save the timestamp of the first tap, and find the difference between the next tap in order to get the time elapsed between them.


You'll want to use touchesBegan: and touchesEnded: methods of UIResponder.

All UIViews are UIResponders. So just override those methods on whatever UIView you want the users to touch. Note that there are four touches methods:

touchesBegan:
touchesMoved:
touchesEnded:
touchesCancelled:

If you override any of them, you are required to override all of them. So for the ones you don't care about, just have practically-empty implementations that just call [super touchesMoved: arg1 withEvent: arg2], etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜