두 개의 하위보기로 작업하고 있습니다. 각각은 고유 할 것이며 자신의 "행동"이 될 것입니다.UIPanGestureRecognizer에서 두 가지 동작을 어떻게 사용합니까?
하위 뷰 1 = 사용자가 뷰 주위 드래그 회전 및 확대 할 것이
하위 뷰 2 사용자가 자신의 화면을 가로 질러 손가락을 이동할 때 화상 각 점 손가락의 터치에 추가 =.
나는 두 가지 모두 UIPanGestureRecognizer를 사용하여 완성했습니다. 제 질문은이 두 가지 행동을 어떻게 분리 할 수 있는가입니다. 하나의 하위 뷰를 추가하고 필요한 작업을 수행 한 다음 다른 하위 뷰를 추가 할 때 이전 작업이 수행되지 않도록 할 수 있습니다. 여기
이 나의 panGesture 방법으로 이루어집니다, 내가 시도 것입니다 :
두 개의 서로 다른 뷰에서 다른 제스처 인식을 원하는 경우에for (UIView * subview in imageView.subviews)
{
if ([subview isKindOfClass:[UIImageView class]])
{
if (subview == _aImageView)
{
CGPoint translation = [panRecognizer translationInView:self.view];
CGPoint imageViewPosition = _aImageView.center;
imageViewPosition.x += translation.x;
imageViewPosition.y += translation.y;
_aImageView.center = imageViewPosition;
[panRecognizer setTranslation:CGPointZero inView:self.view];
}
else if (subview == _bImageView)
{
currentTouch = [panRecognizer locationInView:self.view];
CGFloat distance = [self distanceFromPoint:currentTouch ToPoint:prev_touchPoint];
accumulatedDistance += distance;
CGFloat fixedDistance = 60;
if ([self distanceFromPoint:currentTouch ToPoint:prev_touchPoint] > fixedDistance)
{
[self addbImage];
prev_touchPoint = currentTouch;
}
}
}
}
Ok. 이 작업이 완료되었지만, 어떻게하면 한 번의 제스처 만 호출 할 수 있습니까? 그래서 aImageView를 먼저 하위보기로 추가 한 다음 bImageView를 하위보기로 추가하면 aImageView가 여전히 추가되고 제스처가 활성화됩니다. –