如何知道VC是否使用interactivePopGestureRecognizer完全弹出(滑动返回)

时间:2014-11-20 17:33:26

标签: ios objective-c uinavigationcontroller uigesturerecognizer interactivepopgesture

我正在使用自定义左侧菜单控制器,当UIPanGestureRecognizer仅位于顶级时,可以UINavigationController打开。如果将某些UIViewController推入堆栈,我希望interactivePopGestureRecognizer按预期工作,并在用户从左向右滑动而不是打开左菜单时弹出VC。 为实现这一目标,我将UINavigationController分为如下:

- (void)viewDidLoad {
    [super viewDidLoad];
    //[self.interactivePopGestureRecognizer setDelegate:nil];
    [self.view addGestureRecognizer:[self createPanGestureRecognizer]];
}

- (UIPanGestureRecognizer *) createPanGestureRecognizer {
    SGFPanGestureRecognizer * panRecognizer = [[SGFPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureRecognized:)];
    return panRecognizer;
}

-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if(self.viewControllers.count == 1)
        if(self.view.gestureRecognizers && self.view.gestureRecognizers.count>0)
            for (UIGestureRecognizer * recog in self.view.gestureRecognizers)
            {
                if([recog isKindOfClass:[SGFPanGestureRecognizer class]]) {
                    [self.view removeGestureRecognizer:recog];
                    break;
                }
            }
    [super pushViewController:viewController animated:animated];
}

-(UIViewController *)popViewControllerAnimated:(BOOL)animated {
    UIViewController * vc = [super popViewControllerAnimated:animated];
    if(self.viewControllers.count == 1)
        [self.view addGestureRecognizer:[self createPanGestureRecognizer]];
    return vc;
}

一切正常,除了一个:当我在detailViewController并从左向左滑动时,VC启动“POP”动画,它沿着我的手指。如果我将手势放得太快,那么detailViewController就不会真正弹出并回滚弹出动画。但是,此操作会触发popViewControllerAnimated并且上面的逻辑变得毫无用处。

内容: 那么有没有办法了解是否过早释放滑动到后退的手势才能真正弹出UINavigationController

0 个答案:

没有答案