The number of touches in the state of PAN gestures is over, does not get into iOS

I performed a panorama gesture in the image view. I set the number of touches to 2.

While the user starts panning, he will go into if ([sender state] == UIGestureRecognizerStateBegan), as well as if (sender.numberOfTouches == 2) and im gets the value of no: touches as 2.

But when the user has finished panning, he enters ([sender state] == UIGestureRecognizerStateEnded), but is not included in if (sender.numberOfTouches == 2), and no: of Touches in ends, indicates as 0;

I tested again and again to make sure the strokes ended with two fingers, but the result for the end is zero.

Can someone please help me with this. Please tell me where I am going wrong.

I am 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_]; } } } } 
0
source share
1 answer

This is over, I believe that this is the expected behavior.

The touch is over, so the fingers do not touch it, right? From my point of view, this will always be so.

If you want your event to handle events only when the user touched with two fingers, the best option is set in your gesture handler.

Something like that:

 UIPanGestureRecognizer* p = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureHandler:)]; [p setMaximumNumberOfTouches:2]; [p setMinimumNumberOfTouches:2]; [yourView addGestureRecognizer:p]; 
0
source

All Articles