Search code examples
objective-cxcodeuigesturerecognizeruitouch

location different CGPoint


Hi how do I locate both the cgpoint? he gives me just one.

-(void)gestureLoad {

//GESTURE

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];


...other actions...
}

thanks a lot!


Solution

  • From the description of -[UIGestureRecognizer numberOfTouches]:

    Using the value returned by this method in a loop, you can ask for the location of individual touches using the locationOfTouch:inView: method.

    So, call -locationOfTouche:inView: for each touch to get the corresponding location.