以下是代码。我调试它和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];
}
}