0

팬 제스처 인식기를 만들고보기에 연결하고 싶습니다.x 축 또는 y 축에 대해 이진 팬 제스처 인식기를 만들 수있는 방법

제스처는이를 달성하기 위해 더 나은 방법이 있나요 내가 지금까지 가지고하는

 UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; 
     [self addGestureRecognizer:recognizer]; 

-(void)handlePan:(UIPanGestureRecognizer *)recognizer 
{ 
    UIGestureRecognizerState state = recognizer.state; 
    CGPoint translation = [recognizer translationInView:self]; 
    NSLog(@"state = %d : panned to %@",state,NSStringFromCGPoint(translation)); 


    if ((recognizer.state == UIGestureRecognizerStateChanged) || 
     (recognizer.state == UIGestureRecognizerStateEnded)) 
    { 
     CGFloat translationX = translation.x; 
     if (ABS(translation.y) > 20 && ABS(translation.y) > ABS(translation.x)) 
     { 
      // this is not a valid x pan because the vector has to much "y" movement in it 
     } 
     // need to do similar for x axis 
    } 
} 

꽤 원유 인 axises의 X 중 하나 Y.

에 고려 운동으로 취해야합니까?

답변

0

ScrollView에보기를 포함해도 괜찮다면 directionalLockEnabledYES으로 설정하면 문제가 해결됩니다. UIPanGestureRecognizer에서와 동일하게 보이도록 스크롤 표시기를 꺼낼 수도 있습니다.

+0

슈퍼 뷰에서 다른 제스처를 파괴 할 수 있기 때문에 그렇게 할 수 없습니다. –

관련 문제