views:

428

answers:

1

The function touchesMoved behaves differently in iPhone and simulator.

The repeating interval (refresh rate) of the function touchesMoved is much faster than simulator. Is there a way to deal with the difference?

+1  A: 

Often people are finding this to be a problem because they are doing something intensive in the touchesMoved handler and when events arrive very frequently, it makes the interface appear to lag.

A relatively simple way to deal with this is: First of all, in the touchesMoved handler, store the touch position in a variable that represents the position of whatever is tracking the finger.

Return from the touchesMoved handler immediately. Create an NSTimer object and set your view controller as a delegate of it and have that do whatever re-drawing/view moving behaviour used to be in your touchesMoved handler. Thus, you get a near constant movement regardless of the time between touchesMoved events.

If you're really advanced you can use a custom NSRunLoop instead of using a timer, but that's more than I can explain here :) The general idea is: don't be doing everything in the touch event handlers.

U62
very nice answer. i need some time to change my codes :P
Shivan Raptor