I have a view controller with a label and textfield. I also added a container view which points to another table view controller with one section and 3 rows, basically static table view. I am unable to find any documentation / example which tells you how you pass data between View controller holding the Container View and Table View container embedded in the container view. I want both sided communication ?
The controller embedded in the container view (in storyboard), is automatically added as a childViewController of the controller in which the container view is added. Just to make sense of what I mean, add this line, in your viewDidLoad method of the base controller :
NSLog(@"children : %@", self.childViewControllers);
So lets say in VC1, you add a container view with an embedded controller VC2 (your tableViewController), then the above statement will log VC2 as a child of VC1. To access VC2 from VC1, you just use [self.childViewControllers objectAtIndex:0], and to access VC1 from VC2, just use self.parentViewController.
Hope this helps
If you set things up in a storyboard, you use segues. Just like most everything else in storyboards.
See Access Container View Controller from Parent iOS
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