Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QMUI 感知系统手势返回的接口无法直观判断手势返回的结果,建议优化 #1219

Closed
luoguirong opened this issue Mar 29, 2021 · 6 comments
Labels

Comments

@luoguirong
Copy link

Bug 表现
viewController A实现 - (void)navigationController:(nonnull QMUINavigationController *)navigationController poppingByInteractiveGestureRecognizer:(nullable UIScreenEdgePanGestureRecognizer *)gestureRecognizer viewControllerWillDisappear:(nullable UIViewController *)viewControllerWillDisappear viewControllerWillAppear:(nullable UIViewController *)viewControllerWillAppear 协议, push到B,B手势返回会导致A页面的协议执行,页面B放弃手势返回会导致A页面判断界面发生切换

截图
Bug 现场的界面截图,或者 Xcode 控制台的错误信息截图,有问题的代码截图

如何重现

  1. QMUIDemo的感知系统的手势返回(QDNavigationTransitionViewController)界面push一个页面,手势返回即可重现

预期的表现
手势返回的界面执行协议方法

其他信息

  • 设备: [例如模拟器、iPhone、iPad]
  • iOS 版本: [iOS 14.x]
  • Xcode 版本: [Xcode 12.x]
  • QMUI 版本: [4.x.x]
@MoLice
Copy link
Collaborator

MoLice commented Mar 29, 2021

B手势返回会导致A页面的协议执行

设计如此,手势返回时总共有前后两个 vc 参与,这两个 vc 都会执行这个 delegate 方法。

页面B放弃手势返回会导致A页面判断界面发生切换

这是 QDNavigationTransitionViewController 的 bug,作为功能 Demo,本身它内部判断“手势返回是否成功”的写法是不严谨的,只适用于自身是 topViewController 时,不适用于你描述的那种“再它之上再 push 一个新界面”的场景。
在当前的 QMUI 版本里,这种判断应该写成:

if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
    if (self.transitionCoordinator.cancelled) { // 使用系统的接口来判断手势结果
        [QMUITips showInfo:@"松手了,没有触发界面切换"];
    } else {
        [QMUITips showSucceed:@"松手了,界面发生切换"];
    }
    [self resetStateLabel];
    return;
}

可以看到目前的 QMUI 版本里,单纯通过方法 -[QMUINavigationControllerTransitionDelegate navigationController:poppingByInteractiveGestureRecognizer:viewControllerWillDisappear:viewControllerWillAppear:] 提供的参数无法做到直接获取手势返回的结果,所以下个版本里 QMUI 将会优化这个接口,增加 isCancelled 参数给业务判断,届时请关注 QMUI 版本更新日志的说明,在此之前请参考上文的系统接口来写。

@MoLice MoLice changed the title 感知系统的手势返回bug QMUI 感知系统手势返回的接口无法直观判断手势返回的结果,建议优化 Mar 29, 2021
@MoLice MoLice added the suggest label Mar 29, 2021
@luoguirong
Copy link
Author

感谢!使用self.transitionCoordinator.cancelled也会出现B界面手势返回,A界面触发的问题,目前我这边直接改源码只保留最上面的vc执行delegate方法

@MoLice
Copy link
Collaborator

MoLice commented Mar 29, 2021

感谢!使用self.transitionCoordinator.cancelled也会出现B界面手势返回,A界面触发的问题,目前我这边直接改源码只保留最上面的vc执行delegate方法

这个我之前已经回复了,设计如此,请仔细查看回复。

@luoguirong
Copy link
Author

好的,期待之后的更新

@MoLice
Copy link
Collaborator

MoLice commented Mar 30, 2021

请保持 issue 打开,直到新版本发布。

@MoLice MoLice reopened this Mar 30, 2021
@MoLice
Copy link
Collaborator

MoLice commented Mar 31, 2021

已发布 4.2.3 优化该问题,请尽快按照 Release Note 描述的方式修改业务代码。

@MoLice MoLice closed this as completed Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants