|
@@ -311,24 +311,24 @@ extension UINavigationController: WRFatherAwakeProtocol
|
|
|
}
|
|
|
|
|
|
// swizzling system method: popToViewController
|
|
|
- @objc func wr_popToViewController(_ viewController: UIViewController, animated: Bool) -> [UIViewController]?
|
|
|
- {
|
|
|
- setNeedsNavigationBarUpdate(titleColor: viewController.navBarTitleColor)
|
|
|
- var displayLink:CADisplayLink? = CADisplayLink(target: self, selector: #selector(popNeedDisplay))
|
|
|
- // UITrackingRunLoopMode: 界面跟踪 Mode,用于 ScrollView 追踪触摸滑动,保证界面滑动时不受其他 Mode 影响
|
|
|
- // NSRunLoopCommonModes contains kCFRunLoopDefaultMode and UITrackingRunLoopMode
|
|
|
- displayLink?.add(to: RunLoop.main, forMode: RunLoop.Mode.common)
|
|
|
- CATransaction.setCompletionBlock {
|
|
|
- displayLink?.invalidate()
|
|
|
- displayLink = nil
|
|
|
- popProperties.displayCount = 0
|
|
|
- }
|
|
|
- CATransaction.setAnimationDuration(popProperties.popDuration)
|
|
|
- CATransaction.begin()
|
|
|
- let vcs = wr_popToViewController(viewController, animated: animated)
|
|
|
- CATransaction.commit()
|
|
|
- return vcs
|
|
|
- }
|
|
|
+// @objc func wr_popToViewController(_ viewController: UIViewController, animated: Bool) -> [UIViewController]?
|
|
|
+// {
|
|
|
+// setNeedsNavigationBarUpdate(titleColor: viewController.navBarTitleColor)
|
|
|
+// var displayLink:CADisplayLink? = CADisplayLink(target: self, selector: #selector(popNeedDisplay))
|
|
|
+// // UITrackingRunLoopMode: 界面跟踪 Mode,用于 ScrollView 追踪触摸滑动,保证界面滑动时不受其他 Mode 影响
|
|
|
+// // NSRunLoopCommonModes contains kCFRunLoopDefaultMode and UITrackingRunLoopMode
|
|
|
+// displayLink?.add(to: RunLoop.main, forMode: RunLoop.Mode.common)
|
|
|
+// CATransaction.setCompletionBlock {
|
|
|
+// displayLink?.invalidate()
|
|
|
+// displayLink = nil
|
|
|
+// popProperties.displayCount = 0
|
|
|
+// }
|
|
|
+// CATransaction.setAnimationDuration(popProperties.popDuration)
|
|
|
+// CATransaction.begin()
|
|
|
+// let vcs = wr_popToViewController(viewController, animated: animated)
|
|
|
+// CATransaction.commit()
|
|
|
+// return vcs
|
|
|
+// }
|
|
|
|
|
|
// swizzling system method: popToRootViewControllerAnimated
|
|
|
@objc func wr_popToRootViewControllerAnimated(_ animated: Bool) -> [UIViewController]?
|
|
@@ -416,29 +416,29 @@ extension UINavigationController: WRFatherAwakeProtocol
|
|
|
//==========================================================================
|
|
|
extension UINavigationController: UINavigationBarDelegate
|
|
|
{
|
|
|
- public func navigationBar(_ navigationBar: UINavigationBar, shouldPop item: UINavigationItem) -> Bool
|
|
|
- {
|
|
|
- if let topVC = topViewController,
|
|
|
- let coor = topVC.transitionCoordinator, coor.initiallyInteractive {
|
|
|
- if #available(iOS 10.0, *) {
|
|
|
- coor.notifyWhenInteractionChanges({ (context) in
|
|
|
- self.dealInteractionChanges(context)
|
|
|
- })
|
|
|
- } else {
|
|
|
- coor.notifyWhenInteractionEnds({ (context) in
|
|
|
- self.dealInteractionChanges(context)
|
|
|
- })
|
|
|
- }
|
|
|
- return true
|
|
|
- }
|
|
|
-
|
|
|
- let itemCount = navigationBar.items?.count ?? 0
|
|
|
- let n = viewControllers.count >= itemCount ? 2 : 1
|
|
|
- let popToVC = viewControllers[viewControllers.count - n]
|
|
|
-
|
|
|
- popToViewController(popToVC, animated: true)
|
|
|
- return true
|
|
|
- }
|
|
|
+// public func navigationBar(_ navigationBar: UINavigationBar, shouldPop item: UINavigationItem) -> Bool
|
|
|
+// {
|
|
|
+// if let topVC = topViewController,
|
|
|
+// let coor = topVC.transitionCoordinator, coor.initiallyInteractive {
|
|
|
+// if #available(iOS 10.0, *) {
|
|
|
+// coor.notifyWhenInteractionChanges({ (context) in
|
|
|
+// self.dealInteractionChanges(context)
|
|
|
+// })
|
|
|
+// } else {
|
|
|
+// coor.notifyWhenInteractionEnds({ (context) in
|
|
|
+// self.dealInteractionChanges(context)
|
|
|
+// })
|
|
|
+// }
|
|
|
+// return true
|
|
|
+// }
|
|
|
+//
|
|
|
+// let itemCount = navigationBar.items?.count ?? 0
|
|
|
+// let n = viewControllers.count >= itemCount ? 2 : 1
|
|
|
+// let popToVC = viewControllers[viewControllers.count - n]
|
|
|
+//
|
|
|
+// popToViewController(popToVC, animated: true)
|
|
|
+// return true
|
|
|
+// }
|
|
|
|
|
|
// deal the gesture of return break off
|
|
|
private func dealInteractionChanges(_ context: UIViewControllerTransitionCoordinatorContext)
|