当用户使用滑动手势(UIViewController
)弹出interactivePopGestureRecognizer
或在navigationController上默认返回按钮上按下时,我想记录分析。我找到一种方法来检测用户何时使用滑动手势:
extension AppCoordinator: UINavigationControllerDelegate {
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
if let coordinator = navigationController.topViewController?.transitionCoordinator {
coordinator.notifyWhenInteractionChanges(handleInteraction)
}
}
func handleInteraction(context: UIViewControllerTransitionCoordinatorContext) {
guard !context.isCancelled else {
return
}
//LOG EVENT HERE
}
}
那后退按钮呢?