LocationOfTouch and numberOfTouch

hi I have this recognizer installed with 2 touches, but it returns only one, not two CGPoint

-(void)gestureLoad {

UIGestureRecognizer *recognizer;

recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(numTap2:)];
[(UITapGestureRecognizer *)recognizer setNumberOfTouchesRequired:2];
[self.view addGestureRecognizer:recognizer];
self.tapRecognizer = (UITapGestureRecognizer *)recognizer;
recognizer.delegate = self;
[recognizer release];

}

- (void)numTap2:(UITapGestureRecognizer *)recognizer {

CGPoint location = [recognizer locationInView:self.view];
NSLog(@"x %f y %f",location.x, location.y);

}

as I understand it, I cyclically switch the number of touches in these two ways, but I did not understand how:

-(CGPoint)locationOfTouch:(NSUInteger)touchIndex inView:(UIView *)view {

}

-(NSUInteger)numberOfTouches {

}

Many thanks!

+2
source share
1 answer

In numTap2 use:

CGPoint location = [recognizer locationOfTouch:touchIndex inView:self.view];

where touchIndexis 0 or 1.

+2
source

All Articles