Skip to content

Instantly share code, notes, and snippets.

@roz0n
Created April 16, 2021 01:10
Show Gist options
  • Save roz0n/cad0e98e97e99f29e8f615a21a9172ff to your computer and use it in GitHub Desktop.
Save roz0n/cad0e98e97e99f29e8f615a21a9172ff to your computer and use it in GitHub Desktop.
Remove Previous ViewController in UINavigationController
fileprivate func removePreviousViewController() {
guard let navigationController = self.navigationController else { return }
let controllerToRemove = "ConfirmationViewController"
var allControllers = navigationController.viewControllers
for (index, controller) in allControllers.enumerated() {
let name = String(describing: type(of: controller))
if name == controllerToRemove {
allControllers.remove(at: index)
navigationController.viewControllers = allControllers
break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment