objective-cipadstoryboarduistoryboardseguecontainer-view

custom container view controller + storyboard?


I want to implement my own container view controller. Pls, imagine that this is my ipad

enter image description here

Kind of usual split view controller, but I want to extend it: width of view "a" should be resizable, when I tap view 'B' - view 'C' goes to visible area

enter image description here

For instance in my storyboard, I have 3 container views: AViewController (for A view), BViewController,CViewController and one combined view controller (initial view controller). In combined view controller i will implement embed segues from container view and initialize relationship between container views via following code:

@property ... *aViewController,*bViewController,*cViewController;
    - (void)prepareForSegue:(UIStoryboardSegue *)segue
    sender:(id)sender
    {
    if ([segue.identifier isEqualToString:@"EmbedAViewController"])
    {
    self.aViewController =
    segue.destinationViewController;
    }
    if ([segue.identifier isEqualToString:@"EmbedBViewController"])
    {
    self.bViewController=segue.destinationViewController
    }

   -(void)viewDidLoad
   {
     [super viewDidLoad];
     self.aViewController.bViewController=self.bViewController;
   }

Question1: Is it proper way implement my assignment using storyboards? Question2: What kind of limitations does container view have? Is it a visual replacement of addChildViewController API? If no, where should I implement child-parent relationship? I should use in my combined view controller in prepareForSegue method

 [self addChildViewController:aViewController]; 
    [self.view addSubview:aViewController.view];

Question3: How to put container view outside of visible area at the beginning?

If I somewhere did a mistake or have a big misunderstanding of basic concepts, do not beat me. I did a lot of google-foo, I would really appreciate any help. Great thanks in advance!

Edit:
I want to set up relationship between all of them. "B" view's content depends on "A", and "C" view's content depends on "B".


Solution

  • I think you do have some misconceptions. If you want to implement container view controllers in a storyboard, you don't need to do anything in code. Start with one controller, the one you're calling combined view controller, and drag in 3 container views. Initially, you might want to size them so they are all full height, and make them all fit side by side in the main view. You can then change their sizes and positions using the size inspector, so that C's view starts at the right edge of combine controllers view, that way it will be off screen to start with. You will automatically get three view controllers connected to their respective container views with an embed segue. All three of these controllers will be instantiated at the same time as combined controller. You will need outlets in combined controller to each of its container views, so that you can resize them as necessary in code.