views:

25

answers:

1

Is it common practice to do some kind of debouncing / refractory period for handling user touches?

I have a view based app with quite a few UI objects that are currently using touchUpInside to flip states. I notice that its almost easy to double touch or cycle the state more than once. Since the gameplay is relatively fast it doesn't matter that much but I was curious if other people found that necessary and if so how they implemented it. I imagine I could record the last touch time and disregard new ones within some kind of refractory period, resetting the start time each valid touch. It seems like something would be built into the api to facilitate this though.

A: 

This would probably depend on your app. Like any other coding I'd say don't worry about it until your testing shows that it's a problem (or close to a problem). The UIGestureRecognizer gives you a lot of info on the movements and gives you pretty fine grain control on define what does actually constitute a unique event. If you find your needs exceed those, you can use the raw touch info from the recognizer's to do your own management.

joelm