0

I have 4 gesture recognizers for 1 view.

- (void)createGestureRecognizers {
UITapGestureRecognizer *singleFingerSingleTap = [[UITapGestureRecognizer alloc]
                                                 initWithTarget:self action:@selector(handleSingleFingerSingleTap:)];
singleFingerSingleTap.numberOfTapsRequired = 1;
[self.panelController.view addGestureRecognizer:singleFingerSingleTap];

UITapGestureRecognizer *singleFingerDoubleTap = [[UITapGestureRecognizer alloc]
                                                 initWithTarget:self action:@selector(handleSingleFingerDoubleTap:)];
singleFingerDoubleTap.numberOfTapsRequired = 2;
[self.panelController.view addGestureRecognizer:singleFingerDoubleTap];

[singleFingerSingleTap requireGestureRecognizerToFail:singleFingerDoubleTap];

[singleFingerSingleTap release];
[singleFingerDoubleTap release];

UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc]
                                      initWithTarget:self action:@selector(handlePanGesture:)];
[self.panelController.view addGestureRecognizer:panGesture];
[panGesture release];

UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc]
                                          initWithTarget:self action:@selector(handlePinchGesture:)];
[self.panelController.view addGestureRecognizer:pinchGesture];
[pinchGesture release];}

I need to process Ended state for UIPinchGestureRecognizer, but sometimes it has last state Changed, not Ended how it should be. Does anybody know why? I try to play with setDelaysTouchesEnded: but nothing :(

Bogdan
  • 1,286
  • 9
  • 12

2 Answers2

0

Pinch gesture is gesture of 2 fingers, so you sometimes one finger gets left on screen while other is already up. So, my advice is to handle UIGestureRecognizerStateCancelled and UIGestureRecognizerStateFailed as well as UIGestureRecognizerStateEnded

Daniel
  • 23,129
  • 12
  • 109
  • 154
Nikita Ivaniushchenko
  • 1,425
  • 11
  • 11
0

It's the same issue as the UIRotationGestureRecognizer, it will trigger for each movement and will stop when you stop, but it won't tell you - hey the user removed the fingers, this movement is over.

This is because it's a continuous gesture, not a simple gesture.

You should handle UIGestureRecognizerStateEnded too.

Daniel
  • 23,129
  • 12
  • 109
  • 154