InteractivePopGestureRecognizer导致应用程序冻结 [英] InteractivePopGestureRecognizer causing app freezing

查看:211
本文介绍了InteractivePopGestureRecognizer导致应用程序冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有不同的控制器。当我将controller1推到导航控制器并向后滑动时,一切正常。但是,如果我按下导航控制器1,并进入controller1推控制器2并尝试向后滑动,我得到一个冻结的应用程序。如果返回后退按钮一切正常。

In my app I have different controllers. When I push controller1 to navigation controller and swipe to back, all works good. But, if I push navigation controller1, and into controller1 push controller2 and try to swipe to back I get a frozen application. If go back through back button all works fine.

我怎样才能发现问题?

推荐答案

使用刷卡到弹出手势时,我遇到类似冻结界面的问题。
在我的情况下问题出在controller1.viewDidAppear我禁用了滑动手势: self.navigationController.interactivePopGestureRecognizer.enabled = NO 。因此,当用户开始从contorller2向后滑动时,触发了controller1.viewDidAppear并且在其工作期间禁用了手势。

I had similar problem with freezing interface when using swipe-to-pop gesture. In my case the problem was in controller1.viewDidAppear I was disabling swipe gesture: self.navigationController.interactivePopGestureRecognizer.enabled = NO. So when user started to swipe back from contorller2, controller1.viewDidAppear was triggered and gesture was disabled, right during it's work.

我通过设置控制器1中的self.navigationController.interactivePopGestureRecognizer.delegate = self 并实现 gestureRecognizerShouldBegin:,而不是禁用手势识别器:

I solved this by setting self.navigationController.interactivePopGestureRecognizer.delegate = self in controller1 and implementing gestureRecognizerShouldBegin:, instead of disabling gesture recognizer:

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)] &&
            gestureRecognizer == self.navigationController.interactivePopGestureRecognizer) {
        return NO;
    }
    return YES;
}

这篇关于InteractivePopGestureRecognizer导致应用程序冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆