Search code examples
iosuitouch

iOS touch events not being received in the correct order (touch ended not called at the right time)


So I'm trying to capture the following behavior in this exact sequence

touch 1 STARTED
touch 1 moved
touch 1 moved

touch 2 STARTED
touch 2 moved
touch 2 ENDED

touch 1 moved
touch 1 moved
touch 1 ENDED

But instead they are coming back in the wrong order:

2011-12-02 14:55:37.187 coreplotround2[7396:707] touch 1 STARTED
2011-12-02 14:55:41.182 coreplotround2[7396:707] touch 1 moved
2011-12-02 14:55:41.582 coreplotround2[7396:707] touch 1 moved

2011-12-02 14:55:41.743 coreplotround2[7396:707] touch 2 STARTED
2011-12-02 14:55:41.902 coreplotround2[7396:707] touch 1 moved
2011-12-02 14:55:41.904 coreplotround2[7396:707] touch 2 moved <---- at this point my 2nd finger is released!!

2011-12-02 14:55:45.533 coreplotround2[7396:707] touch 1 moved
2011-12-02 14:55:45.533 coreplotround2[7396:707] touch 1 moved
2011-12-02 14:55:45.533 coreplotround2[7396:707] touch 1 moved
2011-12-02 14:55:45.533 coreplotround2[7396:707] touch 1 moved
2011-12-02 14:55:45.533 coreplotround2[7396:707] touch 1 moved
2011-12-02 14:55:45.549 coreplotround2[7396:707] touch 1 ENDED
2011-12-02 14:55:45.566 coreplotround2[7396:707] touch 2 ENDED

The problem is that the touch 2 ENDED is coming at the same time as touch 1 ENDED even though touch 2 ended MUCH earlier.

I'm using the methods touchesBegan, touchesMoved, touchesEnded.

Anyone know why?


Solution

  • I discovered why. I subclassed an object from the Core Plot graphing library. This object was a subclass of UIView so I expected it to receive touches. I therefore redeclared the touch listeners and tried to experiment see how they behaved.

    I believe something weird is happening in this particular Core Plot object that is screwing with the order of touches. I couldn't tell you what that is.

    I discovered this by creating a new project with an empty view and testing multitouch.

    Instead of subclassing Core Plot, I decided to create a UIView on top of it to intercept the multitouches and then call the appropriate delegates in Core Plot.