I implemeted a pan gesture in the image view.I set the number of touches as 2.
While user start to pan it will enter the if ([sender state] == UIGestureRecognizerStateBegan ) and also in if (sender.numberOfTouches == 2) and im getting the no:of touches as 2.
But when the user ended the pan it is entering ([sender state] ==UIGestureRecognizerStateEnded ) BUT not enetering into if (sender.numberOfTouches == 2) and the the no:of Touches in ended is giving as 0;
I tested again and again to make sure when the touches ended with two finger but the result for ended is zero.
Can anyone please help me with this.kindly please guide me where im going wrong.
I completely stuck at this point.
- (void)panGestureHandler:(UIPanGestureRecognizer *)sender
{
if ([sender state] == UIGestureRecognizerStateBegan ) {
gesture_ = [[SSGesture alloc]init];
if (sender.numberOfTouches == 2) {
startLocation = [sender locationInView:self.view];
CGPoint firstPoint = [sender locationOfTouch:0 inView:self.imageView];
initialPointOne.x = [NSString stringWithFormat:@"%.0f",firstPoint.x];
initialPointOne.y = [NSString stringWithFormat:@"%.0f",firstPoint.y];
initialPointOne.index = @"1";
CGPoint secondPoint = [sender locationOfTouch:0 inView:self.imageView];
SSCoordinate *initialPointTwo = [[SSCoordinate alloc]init];
initialPointTwo.x = [NSString stringWithFormat:@"%.0f",secondPoint.x];
initialPointTwo.y = [NSString stringWithFormat:@"%.0f",secondPoint.y];
initialPointTwo.index = @"2";
gesture_.initialSet = [[NSArray alloc]initWithObjects:initialPointOne,initialPointTwo, nil];
}
} else if ([sender state] ==UIGestureRecognizerStateEnded ) {
NSLog(@"dsfssdf %d",sender.numberOfTouches);
if (sender.numberOfTouches == 2){
SSCoordinate *firstPoint = [gesture_.initialSet objectAtIndex:0];
CGPoint offset = [sender translationInView:self.imageView];
// SSCoordinate *finalPoint = [[SSCoordinate alloc]init];
finalPoint.x = [NSString stringWithFormat:@"%.0f",[firstPoint.x floatValue] + offset.x];
finalPoint.y = [NSString stringWithFormat:@"%.0f",[firstPoint.y floatValue] + offset.y];
SSCoordinate *secondPoint = [gesture_.initialSet objectAtIndex:1];
SSCoordinate *finalPointTwo = [[SSCoordinate alloc]init];
finalPointTwo.x = [NSString stringWithFormat:@"%.0f",[secondPoint.x floatValue] + offset.x];
finalPointTwo.y = [NSString stringWithFormat:@"%.0f",[secondPoint.y floatValue] + offset.y];
gesture_.finalSet = [[NSArray alloc]initWithObjects:finalPoint,finalPointTwo, nil];
if ([gesture_.initialSet count] && [gesture_.finalSet count]) {
[self handleGestureEventWebserviceForGesture:@"pan" withGestureObject:gesture_ andframeId:currentFrame_];
}
}
}
}