Canceling interactive UINavigationController pop gesture does not call UINavigationControllerDelegate methods

前端 未结 3 1366
忘掉有多难
忘掉有多难 2021-02-01 05:04

If you drag the edge of a UIViewController to begin an interactive pop transition within a UINavigationController, the UIViewController un

3条回答
  •  礼貌的吻别
    2021-02-01 05:31

    Swift 3:

    func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
        transitionCoordinator?.notifyWhenInteractionEnds { context in
            guard context.isCancelled, let fromViewController = context.viewController(forKey: UITransitionContextViewControllerKey.from) else { return }
            self.navigationController(self, willShow: fromViewController, animated: animated)
            let animationCompletion: TimeInterval = context.transitionDuration * Double(context.percentComplete)
            DispatchQueue.main.asyncAfter(deadline: .now() + animationCompletion) {
                self.navigationController(self, didShow: fromViewController, animated: animated)
            }
        }
    }
    

提交回复
热议问题