views:

953

answers:

1

Apple has some sample code here under "detecting swipe gestures".

I'd like to detect a two swipe gesture for my application but have no idea where to start. Surprisingly enough I wasn't able to find any samples/examples of similar code. Is there something inherently difficult about the code? Any links or tips you are willing to share would be great.

+1  A: 

Two finger swipes (assuming the swipes are going in the same direction) are similar to regular swipe detection.

instead of

UITouch *touch = [touches anyObject];

You would have to each touch in the NSSet touches.

You will likely want to keep your own set of active touches, so you can track them.

One simple way is done by creating a ivars like below:

NSArray *ActiveTouches;
NSArray *ArrayOfStartTouchPositions;
NSArray *ArrayOfCurrentTouchPositions;

The array can help you keep track of which touches correspond to which start ant current positions.

You have to remember to remove the array items when you get a touches ended event however. The down side to this simple method is extra housecleaning. Once you get the idea, consider some refactoring to simplify the interface and reduce chance of errors.

Kailoa Kadano