Reputation:
I have a Tab Bar Application as I can switch between UIViewController
without losing any types of data. But now I want to change UIViewController
using a UIButton
. I have used the simple storyboard shortcut using Show.
But when I return in the main UIViewController
I've lost all data and function.
How can I switch between UIViewController
without recreating new UIViewController
but coming back to the same.
Upvotes: 1
Views: 64
Reputation: 15331
Don't use a segue. It will instantiate a new instance of the destination view controller.
In the action of the UIButton say something like:
self.tabController.selectedIndex = 1 //or whatever the index of the view controller you want to switch to is
Upvotes: 1