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.
에 고려 운동으로 취해야합니까?
슈퍼 뷰에서 다른 제스처를 파괴 할 수 있기 때문에 그렇게 할 수 없습니다. –