3

如何檢測我的interactivePopGestureRecognizer是否已完成,並將返回(彈出)到先前視圖控制器還是移位不夠。然後當前視圖控制器將回到其正常位置。interactivePopGestureRecognizer - 彈出或返回到視圖控制器

我的代碼:

if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) { 
    [self.interactivePopGestureRecognizer addTarget:self action:@selector(defaultGestureAction:)]; 
} 

- (void)defaultGestureAction:(UIGestureRecognizer *)sender { 

    if (sender.state == UIGestureRecognizerStateBegan || sender.state == UIGestureRecognizerStateChanged) { 

    } else { 

    //this code is fired when I touch up 
    //is there any way to check this action (pop or stay)? 
    } 
} 

回答

1

我不認爲有任何準備使用標誌,說的姿態是積極的還是消極的。

你可以嘗試這樣做,你自己通過分析翻譯點和速度:

- (void)defaultGestureAction:(UIScreenEdgePanGestureRecognizer *)sender 
{ 
    if (sender.state == UIGestureRecognizerStateEnded) 
    { 
     CGPoint translatedPoint = [(UIScreenEdgePanGestureRecognizer*) sender translationInView:[sender view]]; 
     if(translatedPoint.x > self.view.bounds.size.width * 0.5f || [sender velocityInView:self.view].x > 500.0f) 
     { 
      //did trigger translation 
     } 
     else 
     { 
      //did cancel translation 
     } 
    } 
} 
相關問題