How to create a custom view controller container using storyboards in iOS 5

In iOS5, using the storyboard function, I want to create a custom container in which 2 ViewControllers will be ViewControllers . For example, embed a Table view controller, as well as a view controller, as a single ViewController .

That is, one view controller has 2 relationships:

  • for a table view controller.
  • to view the controller, which in turn will look like UIImage or UIButton in it

Does this type of relationship only create using the drag and drop function using the storyboard, and not programmatically?

+23
ios5 storyboard
Nov 14 '11 at 13:40
source share
2 answers

You must have only one view controller to control the scene. However, this viewController may have two other view controllers that control specific subzones in your scene. To do this, you create properties in your scene viewController, in your case, one for your TableViewController and one for your view. I like to keep things together, so I do both of these points of view and create them in the interface builder. To create them in the interface builder, pull an object from the object library and set its type to the corresponding viewController. Plug it into the appropriate outlet you just created in your viewController mode - Note: this is important, otherwise viewController will be released if you use ARC and crash your application. Then move these viewControllers to the view you want them to be monitored, and you're done.

Alternatively, you can instantiate and skip your viewControllers in your viewController mode if you prefer to do this.

Hope this helps.

Edit: when reflecting, this is not a good idea and actually goes against HIG, you should support only one ViewController for each content screen and instead try to create a suitable presentation class and have a single view controller with interaction between different views.

+14
Nov 14 2018-11-11T00:
source share

There is a way to do this, which is not too hacks. It is described in the following URL for UITabBarControllers, which you can use with the first view controller in the list control of the first subquery, and the second with the other. Or, probably, you can adapt the code to work with the UISplitViewController.

http://bartlettpublishing.com/site/bartpub/blog/3/entry/351

Basically, it works by replacing the tabbarcontroller at run time after iOS setup is complete.

0
May 10 '12 at 21:20
source share



All Articles