Avatar
あるViewControllerから指定したViewControllerまでUINavigationControllerも含めて貫通してdismissしてくれるソリューションとかないですかね
10:39 AM
こんなの書いてるんですけど、捨てたい... /// viewControllerから再帰的に画面遷移でtoViewControllerまで戻る fileprivate func recursivelyDismissViewController( _ viewController: UIViewController, toViewController: UIViewController, completion: @escaping (_ dismissedViewController: UIViewController) -> Void) { guard viewController != toViewController else { completion(viewController) return } guard toViewController != self.rootViewController else { completion(viewController) return } if let presentingViewController = viewController.presentingViewController { viewController.dismiss(animated: false, completion: { [weak self] in self?.recursivelyDismissViewController( presentingViewController, toViewController: toViewController, completion: completion) }) } else if viewController.navigationController?.viewControllers.contains(toViewController) ?? false { viewController.navigationController? ._transition_router_popToViewController( toViewController, animated: false) { completion(toViewController) } } else if let nvc = viewController as? UINavigationController, nvc.viewControllers.contains(toViewController) { nvc._transition_router_popToViewController(toViewController, animated: false) { completion(toViewController) } } else { completion(viewController) } } (edited)