使用自定义导航控制器

时间:2016-07-21 06:47:25

标签: ios uinavigationcontroller uigesturerecognizer

我有一个自定义导航控制器声明如下。我的问题是,一旦我实现这一点,后面的滑动手势回到上一个堆栈(interactivepopgesturerecognizer)是行不通的。我该如何启用它?我的应用程序中有很多视图控制器。谢谢。

    #import "NavController.h"

    @interface NavController ()
    {
        BOOL shouldIgnorePushingViewControllers;
    }

    @end

    @implementation NavController

    -(instancetype)init {
        self = [super init];
        self.delegate=self;

        return self;

    }

    -(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
    {
        if (!shouldIgnorePushingViewControllers)
        {
            [super pushViewController:viewController animated:animated];
        }

        shouldIgnorePushingViewControllers = YES;
    }

    - (void)didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
    {
        shouldIgnorePushingViewControllers = NO;
    }

    @end

1 个答案:

答案 0 :(得分:0)

尝试启用属性

self.interactivePopGestureRecognizer.enabled = YES;

init方法