Reputation: 879
I'm working on an iOS app and I have two storyboards and some view controllers in the project like below.
Main.storyboard --- tab bar controller --- Navigation controller --- viewcontroller1 --- storyboard reference --- viewcontroller2
I have another view controller in the tab bar controller, but I just ignored that part for now.
What I want to accomplish here is when I press a button in viewcontroller2, the app takes back the user to viewcontroller1.
I add the ibaction to the button and tried the following codes, but both of them take the user back to viewcontroller1 with no navigation bar and tab bar.
@IBAction func unwindToVC1 (_ segue: UIStoryboardSegue) {
navigationController?.popViewController(animated: true)
}
@IBAction func unwindToVC1 (_ segue: UIStoryboardSegue) {
self.dismiss(animated: true, completion: nil)
self.navigationController?.popViewController(animated: true)
}
Since there is no navigation bar and tab bar when I back from VC2 to VC1, I think what I need to do now is to find a way to back to the root of the Main.storyboard, so I can see both of them appeared(maybe?).
So my question is how can I go back to the root of the storyboard (or in this case I want to see the nav bar and tab bar appeared) from a view controller in different storyboard.
Upvotes: 0
Views: 71
Reputation: 879
I just wrote in the reply to matt, but basically, I had codes to disappear the navigation bar and tab bar in my code and that causes this issue. Adding this line works.
@IBAction func unwindToVC1 (_ segue: UIStoryboardSegue) {
navigationController?.popViewController(animated: true)
}
Upvotes: 0