My question is a follow up to someone else's question. In the image that @ritch provides with his question, he has the following view controllers
"View Controller" -> (Container View)"View Controller" ->["First Controller", "Second Controller"]
For my question, I will rewrite them as
"Parent Controller" -> (Container View)"Child Controller" ->["First Controller", "Second Controller"]
So I am trying to implement the method
- (IBAction)SegmentedControlValueChange:(UISegmentedControl *)sender
{
}
Logically I thought this method should be in "Parent Controller" while, for reference, in "Child Controller" I should have displayContentController
and
FirstController *firstController = [self.storyboard instantiateViewControllerWithIdentifier:@"yourIdentifier"];
Will someone please clarify for me: between SegmentedControlValueChange and instantiateViewControllerWithIdentifier:
- What code goes in the h and m files of "Parent Controller"?
- What code goes in the h and m files of "Parent Controller"?
In the end I took a different approach to what I stated in my question as I felt using storyboard identifiers was bit 'ugly' and incorrect as the views had no segues going to them.
So here is what I did:
I started off by creating classes with XIB files for the view controllers that were going to be shown in the container view. (e.g. FirstController, SecondController etc..)
I then put this in the ViewDidLoad method of my ViewController (the parent view controller - the one with the segmented control)
I then set up three methods to handle the displaying and hiding of the views for the container view
Then finally, I handled the event when a different segmented control value is selected.
Hope this helps.