2014-03-28 1 views

답변

6
  • 특별히 제스처 인식기 클래스가 있으며 iOS 7에 도입되었습니다. UIScreenEdgePanGestureRecognizer입니다. 문서는 here입니다. 확인 해봐.

  • 시뮬레이터에서이를 테스트하려면 가장자리 근처에서 드래그를 시작하십시오 (~ 15 포인트).

  • 또한 각 가장자리에 gestureRecognizer를 만들어야합니다. 서로 모서리를 맞출 수 없기 때문에 UIRectEdgeAll이 작동하지 않습니다.

간단한 예제 here가 있습니다. 희망이 도움이!

1

그럼 당신이 뭔가를 할 수 있습니다,이 예제는 제스처를 추가 사용자 와이프가 화면 전체의

최초의 오른쪽에서 내부 20 픽셀 때에 만 팬 제스처 작업 할 경우입니다 창문

- (void)addGestures { 
if (!_panGesture) {  
_panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)]; 
[_panGesture setDelegate:self]; 
[self.view addGestureRecognizer:_panGesture]; 
} 
} 

에 당신이 받았다 터치 이에 따라

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {  
CGPoint point = [touch locationInView:self.view]; 
if (gestureRecognizer == _panGesture) {  
return [self slideMenuForGestureRecognizer:gestureRecognizer withTouchPoint:point]; 
} 
return YES; 
} 

당신의 작업을 수행 한 후 팬 동작하고 있는지 체크를 추가 한 후 다음은 터치가 원하는 지역에 있는지 확인하는 방법입니다.

-(BOOL)isPointContainedWithinBezelRect:(CGPoint)point { 
    CGRect leftBezelRect; 
    CGRect tempRect; 
//this will be the width between CGRectMaxXEdge and the screen offset, thus identifying teh region 
    CGFloat bezelWidth =20.0; 
    CGRectDivide(self.view.bounds, &leftBezelRect, &tempRect, bezelWidth, CGRectMaxXEdge); 
    return CGRectContainsPoint(leftBezelRect, point); 
    } 
관련 문제