I have 6 viewControllers in following manner.
VCA
,VCB
,VCC
,VCD
,VCE
,VCF
.
mainVC
-->VCA
-->VCB
-->VCC
-->VCD
...VCE
mainVC
-->VCA
-->VCD
...VCF
(-->) are connected by segues while (...) VCE
and VCF
are programatically pushed in navigationController
.
My question is how can I pop multiple viewControllers from VCD
,VCE
or VCF
to VCA
on Back
UIBarButton on navigationController
According to this StackOverFlow questions Link and Link :-
Tried this code but it didn't work.
override func viewDidLoad {
super.viewDidLoad()
self.navigationItem.hidesBackButton = true
let newBackButton = UIBarButtonItem(title: "Back", style: UIBarButtonItemStyle.plain, target: self, action: #selector(YourViewController.back(sender:)))
self.navigationItem.leftBarButtonItem = newBackButton
}
func back(sender: UIBarButtonItem) {
let presentingViewController = self.presentingViewController
self.dismissViewControllerAnimated(false, completion: {
presentingViewController!.dismissViewControllerAnimated(true, completion: {}) //.dismiss(animated:true, completion:{})
})
}