Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IBOutlet link to embedded container view controller

I have a complex iPad view that I manage by having several view controllers. I previously (before iOS6/Xcode 4.5) did this by allocating my view controllers in code, and hooked up the various views to them though links to the master view.

What I would like to do is use the new UIContainerView container views to embed the view controllers in the storyboard file. I don't seem to be able to make an IBOutlet link to the embedded view controller to the master controller.

Is it possible to do this? Or to retrieve the embedded controller via a tag or something in the code?

This question is SPECIFICALLY about using container views

like image 351
Dan F Avatar asked Oct 01 '12 15:10

Dan F


People also ask

How do I embed a view controller?

Just drag a container view out into your main view controller and use the embed segue from it to your embedded view controller. It will properly set up all the view controller hierarchy for you.

How do I embed a view controller in navigation controller storyboard?

In your storyboard, select the initial view controller in your hierarchy. With this view controller selected, choose the menu item Editor -> Embed In -> Navigation Controller .


1 Answers

Another option for some cases is to capture the embedded controller using -prepareForSegue:sender:.

For example, if I have a UINavigationController embedded within a CustomContainerViewController, I can name the embed segue embedContentStack in the storyboard and capture it in CustomContainerViewController via

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {     if ([segue.identifier isEqualToString:@"embedContentStack"]) {         // can't assign the view controller from an embed segue via the storyboard, so capture here         _contentStack = (UINavigationController *)segue.destinationViewController;     } } 
like image 115
PlayfulGeek Avatar answered Oct 18 '22 18:10

PlayfulGeek