0

我在一些视图控制器中添加了“interactivePopGestureRecognizer”,也在 topbar 上给出了返回按钮。当用户当时使用 Pop Gesture 和推送/弹出视图时,它将冻结顶部导航控制器视图。一段时间后,它会因“[viewcontroller hash]: message sent to deallocated instance”而崩溃。

方法

-(void)viewDidAppear:(BOOL)animated{
         [super viewDidAppear:animated];

            //Pop GESTURE
            if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
                self.navigationController.interactivePopGestureRecognizer.enabled = true;
                self.navigationController.interactivePopGestureRecognizer.delegate = self;
    }
    -(void)viewDidDisappear:(BOOL)animated
    {
        [super viewWillDisappear:animated];
        //Remove Pop Gesture
        if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
            self.navigationController.interactivePopGestureRecognizer.enabled = false;
            self.navigationController.interactivePopGestureRecognizer.delegate = nil;
        }
    }

DELEGATE METHOD
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    // add whatever logic you would otherwise have

    return YES;
}

我有 TabBar 类型的应用程序。

4

1 回答 1

0

崩溃将由您以某种方式无法执行来解释

self.navigationController.interactivePopGestureRecognizer.delegate = nil;

viewDidDisappear. 您能否通过在调试器中单步执行您的委托来确认您的委托实际上已被删除?

于 2015-10-19T11:32:53.647 回答