3

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".

Neil Galiaskarov
  • 5,015
  • 2
  • 27
  • 46

1 Answers1

5

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.

rdelmar
  • 103,982
  • 12
  • 207
  • 218
  • Thanks for your answer! I want to set up relationship between 'A' and 'B'. 'B' view's content depends on what is chosen in 'A'-view. – Neil Galiaskarov Feb 16 '13 at 17:52
  • Actually, it works. I used when 'A' is table view controller and 'B' simple ui view controller. And I passed data between them with no problems. I wanted to know will i have many pitfalls if i continue this way? – Neil Galiaskarov Feb 16 '13 at 18:02
  • 1
    @НаильГалиаскаровб, It depends on how you are referencing one controller from another. A,B, and C will all be child view controllers of combined view controller, so you can get a reference to them from the childViewControllers property. – rdelmar Feb 16 '13 at 18:49
  • that was one of the questions. if i put container view 'A', it means that it is childviewcontroller of combinedviewcontroller and it is visual replacement of parent-child relationship? – Neil Galiaskarov Feb 17 '13 at 15:06
  • @НаильГалиаскаров, I don't understand what you mean by "visual replacement of parent-child relationship". – rdelmar Feb 17 '13 at 16:42
  • Ok, i will try to rephrase. if I put container views in my combined view controller, then if i want to access [combinedVC childViewControllers][0], while debugging console says that this array is empty. Why? – Neil Galiaskarov Feb 18 '13 at 08:13
  • @НаильГалиаскаров, I don't know -- it shouldn't be empty. There must be something wrong with the way you set them up, or where you're trying to access them. Where did you have that log? – rdelmar Feb 18 '13 at 15:28