I have 2 storyboards say A and B. Storyboard A has multiple view controllers. After some user action I switch from storyboard A to storyboard B. How can I go back to previous storyboard A on clicking back button and go back to same view controller I initially came from.
I can't do as given below because I will not have the old navigation stack of A.
let storyboard = UIStoryboard(name: "A", bundle: nil)
let vc = storyboard.instantiateInitialViewController() as UIViewController!
presentViewController(vc, animated: true, completion: nil)
The "Back" button should be linked to something like this:
self.dismissViewControllerAnimated(true, completion: nil)
if your viewcontrollers are embedded in a navigationcontroller you can do the following:
to move from storyboard A to storyboard B
let storyboard = UIStoryboard(name: "B", bundle: nil)
let vc = storyboard.instantiateInitialViewController() as UIViewController!
navigationController?.pushViewController(vc, animated: true)
to get back from storyboard B to storyboard A
navigationController?.popViewControllerAnimated(true)
(of course the the initial viewcontroller in storyboard B should not be a navigationcontroller but a regular viewcontroller)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With