당신은 어쨌든 touchesBegan
및 touchesMoved
를 사용하도록 서브 클래스해야합니다. 나는 당신이 말한 것처럼 UISwipeGestureRecognizerDirectionUp | UISwipeGestureRecognizerDirectionLeft
을 할 것이고 두 개의 CGRect
을 수락 할 수있는 시작점 하나와 수용 가능한 끝점 하나를 설정합니다. 그런 다음 UIGestureRecognizerDelegate
메서드 gestureRecognizer:shouldReceiveTouch:
을 사용하고 CGRectContainsPoint()
을 사용하여 터치 포인트가 허용되는 시작 rect에 있는지 확인하십시오. 그런 다음 UISwipeGestureRecognizer
서브 클래스에서 (내 생각에는) touchesEnded:withEvent:
을 무시하고 끝 부분 터치가 허용되는 rect에 있는지 확인하십시오. 그렇지 않은 경우 상태를 UIGestureRecognizerStateCancelled
(또는 사용자가 제스처를 취소해야 함)로 설정합니다. 또한 첨부 된보기의 속성이 multipleTouchEnabled
인지 확인하십시오. 나는 실제로 이것을 시도하지는 않았지만, 그런 종류의 일이 그것을해야한다. 행운을 빕니다!
편집
사실, 당신은 허용 시작/끝 지점에 대한 특정 RECT 값에 대해 걱정할 필요가, 그것은 독립적 인 장치, 당신이 할 수있는 만들고 싶어하지 않은 경우 :
//swap in whatever percentage of the screen's width/height you want in place of ".75f"
//set the origin for acceptable start points
CGFloat startRect_x = self.view.frame.size.width * .75f;
CGFloat startRect_y = self.view.frame.size.height * .75f;
//set the size
CGFloat rectWidth = self.view.frame.size.width - startRect_x;
CGFloat rectHeight = self.view.frame.size.height - startRect_y;
//make the acceptable start point rect
CGRect startRect = CGRectMake(startRect_x, startRect_y, rectWidth, rectHeight);
//set the origin for the accepable end points
CGFloat endRect_x = self.view.center.x - rectWidth/2;
CGFloat endRect_y = self.view.center.y - rectHeight/2;
//make the acceptable end point rect
CGRect endRect = CGRectMake(endRect_x, endRect_y, rectWidth, rectHeight);
을