@@ -135,8 +135,6 @@ extension UINavigationController {
135135 _ transition: AnyNavigationTransition ,
136136 interactivity: AnyNavigationTransition . Interactivity = . default
137137 ) {
138- backDeploy96852321 ( )
139-
140138 if defaultDelegate == nil {
141139 defaultDelegate = delegate
142140 }
@@ -147,6 +145,30 @@ extension UINavigationController {
147145 customDelegate. transition = transition
148146 }
149147
148+ swizzle (
149+ UINavigationController . self,
150+ #selector( UINavigationController . pushViewController) ,
151+ #selector( UINavigationController . pushViewController_animateIfNeeded)
152+ )
153+
154+ swizzle (
155+ UINavigationController . self,
156+ #selector( UINavigationController . popViewController) ,
157+ #selector( UINavigationController . popViewController_animateIfNeeded)
158+ )
159+
160+ swizzle (
161+ UINavigationController . self,
162+ #selector( UINavigationController . popToViewController) ,
163+ #selector( UINavigationController . popToViewController_animateIfNeeded)
164+ )
165+
166+ swizzle (
167+ UINavigationController . self,
168+ #selector( UINavigationController . popToRootViewController) ,
169+ #selector( UINavigationController . popToRootViewController_animateIfNeeded)
170+ )
171+
150172 #if !os(tvOS) && !os(visionOS)
151173 if defaultEdgePanRecognizer. strongDelegate == nil {
152174 defaultEdgePanRecognizer. strongDelegate = NavigationGestureRecognizerDelegate ( controller: self )
@@ -196,28 +218,6 @@ extension UINavigationController {
196218 #endif
197219 }
198220
199- private func backDeploy96852321( ) {
200- func forceAnimatedPopToViewController( ) {
201- swizzle (
202- UINavigationController . self,
203- #selector( UINavigationController . popToViewController) ,
204- #selector( UINavigationController . popToViewController_forceAnimated)
205- )
206- }
207-
208- if #available( iOS 16 . 2 , macCatalyst 16 . 2 , tvOS 16 . 2 , * ) { } else {
209- #if targetEnvironment(macCatalyst)
210- let major = ProcessInfo . processInfo. operatingSystemVersion. majorVersion
211- let minor = ProcessInfo . processInfo. operatingSystemVersion. minorVersion
212- if ( major, minor) < ( 13 , 1 ) {
213- forceAnimatedPopToViewController ( )
214- }
215- #else
216- forceAnimatedPopToViewController ( )
217- #endif
218- }
219- }
220-
221221 @available ( tvOS, unavailable)
222222 @available ( visionOS, unavailable)
223223 private func exclusivelyEnableGestureRecognizer( _ gestureRecognizer: UIPanGestureRecognizer ? ) {
@@ -232,8 +232,36 @@ extension UINavigationController {
232232}
233233
234234extension UINavigationController {
235- @objc private func popToViewController_forceAnimated( _ viewController: UIViewController , animated: Bool ) -> [ UIViewController ] ? {
236- popToViewController_forceAnimated ( viewController, animated: true )
235+ @objc private func pushViewController_animateIfNeeded( _ viewController: UIViewController , animated: Bool ) {
236+ if let transitionDelegate = customDelegate {
237+ pushViewController_animateIfNeeded ( viewController, animated: transitionDelegate. transition. animation != nil )
238+ } else {
239+ pushViewController_animateIfNeeded ( viewController, animated: animated)
240+ }
241+ }
242+
243+ @objc private func popViewController_animateIfNeeded( animated: Bool ) -> UIViewController ? {
244+ if let transitionDelegate = customDelegate {
245+ return popViewController_animateIfNeeded ( animated: transitionDelegate. transition. animation != nil )
246+ } else {
247+ return popViewController_animateIfNeeded ( animated: animated)
248+ }
249+ }
250+
251+ @objc private func popToViewController_animateIfNeeded( _ viewController: UIViewController , animated: Bool ) -> [ UIViewController ] ? {
252+ if let transitionDelegate = customDelegate {
253+ return popToViewController_animateIfNeeded ( viewController, animated: transitionDelegate. transition. animation != nil )
254+ } else {
255+ return popToViewController_animateIfNeeded ( viewController, animated: animated)
256+ }
257+ }
258+
259+ @objc private func popToRootViewController_animateIfNeeded( animated: Bool ) -> UIViewController ? {
260+ if let transitionDelegate = customDelegate {
261+ return popToRootViewController_animateIfNeeded ( animated: transitionDelegate. transition. animation != nil )
262+ } else {
263+ return popToRootViewController_animateIfNeeded ( animated: animated)
264+ }
237265 }
238266}
239267
0 commit comments