0

我有 4 个手势识别器用于 1 个视图。

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

我需要处理 UIPinchGestureRecognizer 的结束状态,但有时它的最后一个状态已更改,而不是应如何结束。有人知道为什么吗?我尝试玩 setDelaysTouchesEnded: 但没有:(

4

2 回答 2

0

捏合手势是两根手指的手势,因此有时您的一根手指会留在屏幕上,而另一根手指已经抬起。所以,我的建议是处理UIGestureRecognizerStateCancelledUIGestureRecognizerStateFailed以及UIGestureRecognizerStateEnded

于 2012-08-20T14:24:28.933 回答
0

这与 的问题相同UIRotationGestureRecognizer,它会触发每个动作并在您停止时停止,但它不会告诉您 - 嘿用户移开手指,这个动作结束了。

这是因为它是一个连续的手势,而不是一个简单的手势。

你也应该处理UIGestureRecognizerStateEnded

于 2012-08-20T14:45:56.623 回答