gpt4 book ai didi

ios - InteractivePopGestureRecognizer 导致应用卡住

转载 作者:IT王子 更新时间:2023-10-29 08:10:11 24 4
gpt4 key购买 nike

在我的应用程序中,我有不同的 Controller 。当我将 controller1 推到导航 Controller 并向后滑动时,一切正常。但是,如果我将导航 controller1 插入 controller1 推 controller2 并尝试向后滑动,我会得到一个卡住的应用程序。如果通过后退按钮返回一切正常。

我怎样才能发现问题?

最佳答案

我在使用滑动弹出手势时遇到了类似的卡住界面问题。在我的例子中,问题出在 controller1.viewDidAppear 我正在禁用滑动手势:self.navigationController.interactivePopGestureRecognizer.enabled = NO。因此,当用户开始从 contorller2 向后滑动时,controller1.viewDidAppear 被触发并且手势被禁用,就在它工作期间。

我通过在 controller1 中设置 self.navigationController.interactivePopGestureRecognizer.delegate = self 并实现 gestureRecognizerShouldBegin: 来解决这个问题,而不是禁用手势识别器:

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

关于ios - InteractivePopGestureRecognizer 导致应用卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21221581/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com