Other new and powerful tool in iOS 5 is View Controller containment, through view controller hierarchy manipulation; the "one screenful of content equals one UIViewController" rule is no longer enforced. Now you can get better code reuse since UIViewController has a list of "child" view controllers, one in charge of controlling one branch of its view hierarchy; UIViewController can transfer the control of one view to another view controller.
But, what if you try to mix both technologies? Storyboarding does not have a direct way to define child view controllers. Some people (as in here) are doing it the wrong way: add an "Object" to the scene, change its class and add some code. In some situations it may work, but it's not the way to go: try to do it with a child UITableViewController with static cells.
How to do it then?
First of all: create a new scene in your storyboard with your UITableViewController subclass and add your static cells as usual. Do not connect this newly created scene with any segue, but don't forget to assign the proper value to the identifier field of your view controller
Now, in your parent view controller add some code in its -awakeFromNib and -viewDidLoad method implementation:
-(void)awakeFromNib{
// instantiate and assign the child view controller to a property to have direct reference to it in
self.propiedadesVC=[self.storyboard instantiateViewControllerWithIdentifier:@"BGRutaPropiedadesListViewController"];
// configure your child view controller
self.propiedadesVC.ruta=_ruta;
// add your child view controller to children array
[self addChildViewController:self.propiedadesVC];
[self.propiedadesVC didMoveToParentViewController:self];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// configure chld view controller view's frame
self.propiedadesVC.view.frame=CGRectMake(640, 0, self.scrollView.bounds.size.width, self.scrollView.bounds.size.height);
// add child's view to view hierarchy
[self.scrollView addSubview:self.propiedadesVC.view];
}
Simple and straightforward. Storyboarding rocks!
Where and how to declare this:
ResponderEliminarself.propiedadesVC.ruta=_ruta;
propiedadesVC is declared at the class @interface like any other property
EliminarIt's the previously mentioned custom UITableViewController subclass.
In this case, "ruta" is the model object: the table view controller will populate its table view with data from it.