8

새로운 iOS 7 UINavigationController에는보기를 전환 할 수있는 스 와이프 동작이 있습니다. 제스처를 감지하거나 가로채는 방법이 있습니까?iOS 7 uinavigationcontroller 어떻게 스 와이프를 감지하나요?

+2

'사용 안함'. 당신은 당신이 "장난 꾸러기"처럼 들리도록 만들었습니다. –

+0

그냥 "uinavigationcontroller에서 스 와이프 제스처를 비활성화하는 방법"과 비슷한 주제를 읽었 기 때문입니다. 그래서 나는 명확하고 싶었다 ^^ – Steven

답변

27

대화 형 팝 제스처 인식기는 UINavigationControllerinteractivePopGestureRecognizer 속성을 통해 노출됩니다. 당신은 제스처 인식의 대상으로 자신의 컨트롤러를 추가하고 적절하게 응답 할 수 있습니다 :

@implementation MyViewController 

... 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    [self.navigationController.interactivePopGestureRecognizer addTarget:self 
                    action:@selector(handlePopGesture:)]; 
} 


- (void)handlePopGesture:(UIGestureRecognizer *)gesture 
{ 
    if (gesture.state == UIGestureRecognizerStateBegan) 
    { 
     // respond to beginning of pop gesture 
    } 
    // handle other gesture states, if desired 
} 

... 

@end 
+0

완벽! 그것은 내가 당신에게 감사하고 싶었던 것이다. – Steven

7

여기 스위프트에, Austin's answer입니다. this post을 사용하여 선택기를 구성하면 다음과 같은 결과가 나타납니다.

override func viewDidLoad() { 
    super.viewDidLoad() 
    self.navigationController?.interactivePopGestureRecognizer?.addTarget(self, action:#selector(self.handlePopGesture)) 
} 

func handlePopGesture(gesture: UIGestureRecognizer) -> Void { 
    if gesture.state == UIGestureRecognizerState.Began { 
     // respond to beginning of pop gesture 
    } 
} 
+0

내게 응답하지 않습니다 ... 제스처 인식에서 "hello"를 인쇄하고 싶었습니다. –

관련 문제