For my requirement, I have to go back to my rootviewcontroller (tabbar) but It have many page present on it.
example flow
my tabbar (have 4 tabs each tab has own navigation ) -> push(vc1) -> present nav(vc2) -> push vc3 -> present nav(vc4)
If I want to close all viewcontroller ( vc1 - vc4 ) How to dismiss them by one function ?
You can use
UIViewController.dismiss(animated:completion:)call on the base view controller that started presentation from tab bar (root level).Given this hierarchy
You can walk back the presentation hierarchy like following -
Above is merely an example of how you can find the correct view controller instance to call dismiss on in the view hierarchy. This is definitely not well suited for dynamic number of presentation layers.
You can -
presentingViewControlleruntil it findsnilfor the root level).