Dimiss View Controller to Specific View Controller Issue

56 Views Asked by At

i have VC1 and i present VC2 and then multiple VC's after it like in a flow,

VC3 -> VC4 -> VC5

Now i want VC5 to dismiss to VC2, i have searched and tried code and call the view controller by name but it isn't working fine, can anyone let me know how i can get this flow and dismiss to specific view controller?.

2

There are 2 best solutions below

8
Subramanian Mariappan On BEST ANSWER

You can use unwindSegues to "go back" one or more steps in your navigation hierarchy.

Refer https://developer.apple.com/library/archive/technotes/tn2298/_index.html

1
Madhuri Doppalapudi On
  let viewControllers: [UIViewController] = self.navigationController!.viewControllers as [UIViewController]
  self.navigationController!.popToViewController(viewControllers[viewControllers.count - 3], animated: true)

Note: here 3 indicates no of controllers