I have a main UIViewController and named AddInformationController. In this mainViewController I have two UIContainerView. Each of them embed with a UITableViewController. The table view controllers are named InformationSegmentController and ResultSegmentController.
I put this in AddInformationController:
InformationSegmentController *isc = [self.storyboard instantiateViewControllerWithIdentfier:@"InformationSegmentController"];
ResultSegmentController *rsc = [self.storyboard instantiateViewControllerWithIdentifier: @"ResultSegmentController"];
[self addChildViewController: isc];
[self addChildViewController: rsc];
In either the InformationSegmentController class or ResultSegmentController class, I tried to Log this:
NSLog(@"%@",self.parentViewController);
But unfortunately, it is a nil. How can I get the parentViewController correctly? Do I have to use the prepareForSegue?
// Question Update:
I found that I don't have to call addChildViewController method again if I create those childViewControllers directly in my storyboard.
I have tried to NSLog(@"%@", self.childViewControllers) in my AddInformationController and the result contains InformationSegmentController class and ResultSegmentController class.
But the problem is when I call NSLog(@"%@", self.parentViewController) on both childViewContorllers in viewDidLoad, the results is nil.