I have a UITabBarController set up in storyboard. I want to pass a dictionary of data from the tab bar controller for use in the appropriate child tab, which is a standard UIViewController.
This seems like a long questions to answer, but I really don't know where to start. I'm looking for the easiest way through this. Must I make the tabs function programmatically? Pointing me towards any useful developer documentation would also be much appreciated.
-Austin
p.s. i'm new and have so far depended on storyboard for viewcontroller transitions
Your best bet is to use notifications.
In your tab bar, you would do this:
Then in your child tab ViewController, you would "listen" for that notification.
If you got an
UINavigationController
as one of yourUITabBarController
view controllers, you can do the following:Using Swift
If you have
UINavigationController
as one of the tabs inUITabBarController
, you want to get the instance of the child view controller instead of creating a new instance and push it to the navigation view controller before changing the tab view index. You can do this...This sample code assumes the Navigation Controller is at the first tab (index 0) and "childViewController" is embedded in the Navigation Controller.
With Swift:
It took a couple of days, but I discovered a simple solution. In my TabBarController's viewDidLoad method, I can access and set attributes of my the tabbed subviews using
or whatever index you wish to access.
Saving that as an instance of my tab1_viewController gives me a pointer to the object, from which I can get and set my property values. This was initially unclear because storyboard created the tab_viewController objects for me. I never had a chance to initialize them the way I wanted to!
Got this working...
I have 3 view controller, I have to pass the array from one to another..
Here is what I did
Appending the data to one of Tab View Controller
And after that, load the view controller, that's it