gestureRecognizer是UIGestureRecognizerStateEnded,仍未输入if(recognizer.state == UIGestureRecognizerStateEnded)条件

时间:2013-03-26 13:02:54

标签: iphone objective-c ios6 uigesturerecognizer

以下是代码。我调试它和coe知道即使Recognizer.state是UIGestureRecognizerStateEnded,它也不会输入if条件。 请告诉我是解决方案。谢谢。

- (void)pan:(UIPanGestureRecognizer *)recognizer
{
    if(recognizer.state == UIGestureRecognizerStateChanged || recognizer.state == UIGestureRecognizerStateEnded)
    {
        CGPoint dragPoint = [recognizer translationInView:self.mapView];
        if(dragPoint.x > 0)
        {
            if(recognizer.state == UIGestureRecognizerStateEnded)
            {
                NSLog(@"x>0 & stateEnded");
               // some translation happens
            }
            else if(recognizer.state == UIGestureRecognizerStateChanged)
            {
                NSLog(@"x>0 & stateChanged");
               // some translation happens
            }
        }
        else if(dragPoint.x < 0)
        {
            if(recognizer.state == UIGestureRecognizerStateEnded)
            {
                NSLog(@"x<0 & stateEnded");
              // some translation happens
            }
            else if(recognizer.state == UIGestureRecognizerStateChanged)
            {
               NSLog(@"x<0 & stateChanged");
              // some translation happens
            }
        }
        [recognizer setTranslation:CGPointZero inView:self.mapView];
    }
}

0 个答案:

没有答案