QMUI_iOS icon indicating copy to clipboard operation
QMUI_iOS copied to clipboard

当self.interactivePopGestureRecognizer.enabled = NO时,UIViewController.qmui_poppingByInteractivePopGestureRecognizer等属性的状态就不正确了

Open CloudlessMoon opened this issue 5 years ago • 1 comments

Bug 表现 当self.interactivePopGestureRecognizer.enabled = NO时,UIViewController.qmui_poppingByInteractivePopGestureRecognizer等相关的属性状态就不正确了,因为handleInteractivePopGestureRecognizer并不会回调,从而导致UIViewController.qmui_navigationBarMaxYInViewCoordinator中的代码可能判断不正确。 其次,设置全屏手势时,shouldPopViewControllerByBackButtonOrPopGesture也会失效,有什么办法可以既保持全屏手势,又不影响QMUI的状态判断呢

截图

如何重现

预期的表现

其他信息

  • 设备: iPhone
  • iOS 版本: [iOS 14.3]
  • Xcode 版本: [Xcode 12.3]
  • QMUI 版本: [4.2.2]

CloudlessMoon avatar Jan 18 '21 13:01 CloudlessMoon

记录一下当self.interactivePopGestureRecognizer.enabled = NO时,需要开发者自行实现的方法: 1、「非必须」UINavigationController+QMUI.m- (BOOL)shouldForceEnableInteractivePopGestureRecognizer

也就是forceEnableInteractivePopGestureRecognizer, 不过,既然开发者自行实现了pop手势,这个方法就失去了其意义

2、「必须」UINavigationController+QMUI.m- (BOOL)canPopViewController:(UIViewController *)viewController byPopGesture:(BOOL)byPopGesture

也就是shouldPopViewControllerByBackButtonOrPopGesture,需要开发者在- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer手势代理中实现

3、「必须」QMUINavigationController.m[self.interactivePopGestureRecognizer addTarget:self action:@selector(handleInteractivePopGestureRecognizer:)];

需要开发者给自己的pop手势添加Target-Action,实现- (void)handleInteractivePopGestureRecognizer:(UIScreenEdgePanGestureRecognizer *)gestureRecognizer

另外建议- (void)navigationController:(nonnull QMUINavigationController *)navigationController poppingByInteractiveGestureRecognizer:(nullable UIScreenEdgePanGestureRecognizer *)gestureRecognizer viewControllerWillDisappear:(nullable UIViewController *)viewControllerWillDisappear viewControllerWillAppear:(nullable UIViewController *)viewControllerWillAppear这个代理方法中gestureRecognizer的类型为UIGestureRecognizer

4、「未知」UIViewController (QMUINavigationButton)accessibilityPerformEscape 判断了当self.interactivePopGestureRecognizer.enabled = NO的情况

如上所述,实现以上方法才能保证QMUI的各项功能正常使用,如果有遗漏的,请大家补充

CloudlessMoon avatar Jan 19 '21 01:01 CloudlessMoon