Another option: if you put the following in B, it will remove it from the stack when C is presented. Then the stack looks like [A,C], so it will go straight back to A.
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
if let nav = self.navigationController {
let vcs = nav.viewControllers.filter {(vc) in
return (vc as? MyViewController) == nil
}
self.navigationController?.setViewControllers(vcs, animated: false)
}
}
source
share