I would not use the ContainerViewController for the storyboard. They are more suitable for use in storyboards when you already know how many controllers should be on the screen. Instead, you want to dynamically add deletion controllers to your code.
First, create a controller that handles simple views (panels). Put all your logic so that you can add a panel, delete it and resize existing views when adding / removing a new panel. I will also not use restrictions, it will be too difficult. When you add a panel, you will need to know which sides surround it, grab them and add restrictions to it. When deleting a panel, you will also need to remove some restrictions (not all) of certain panels .. a lot.
However, if you use frames, you can simply build an equation that takes the width and height of the container and recounts all the view frames.
Once you do this, just add controllers to these panels (views), for example:
//Here self would be the containerController and paneContainer one of the pane views UIViewController *newPaneVC = [UIViewController new]; newPaneVC.view.frame = [self calculateFrameForNewPane]; [self.paneContainer addSubview:newPaneVC.view]; [self addChildViewController:newPaneVC]; [newPaneVC didMoveToParentViewController:self]; //Add resizing masks to make sure new VC resizes with superview changes (example: when more panes are added/removed) [newPaneVC.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
Finally, take a look at this library: https://github.com/yatsu/treemapkit
This was done 3 years ago, but I used it in the project and worked well. This gives you the logic to draw different sizes on the screen based on an array of values. You add and remove panels with this and use delegates to return cells (panels) with the controller already added.
source share