Without a doubt, we have never liked storyboards like this. Since iOS 5, Apple has provided the storyboard editor in its new IDE version and "upgraded" its Object Library, especially UITableView, In the storyboard editor. In addition to providing cells using the traditional DataSource programming method, the new UITableView provides two types of cells for uidesign without leaving the ViewController design field: Template cells and static cells.
The former is needless to say. Once you have used it, you will never leave it alone. For the latter, there has always been a huge defect-static cells can only be used in the UITableViewController built in the SDK. If the static cells are not displayed in the programmer's own ViewController, even the compiler prompts the error message "Illegal Configuration: Static table views are only valid when embedded in UITableViewControllerinstances ".
This is indeed a pity, but apple (Xcode 5) has not addressed this defect in its provided IDE so far.
How can this problem be solved? We do need to use static cells in our ViewController.
We can be inspired by the Container View after Xcode4.5. With the ContainerView provided after Xcode4.5.1, We can "embed" a UITableViewController containing static cells into our own ViewController.
The procedure is as follows:
1. Drag a conventional TableViewController into the story board.
2. Use static cells in TableViewController.
3. Drag a conventional ViewController into the story version. <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> Http://www.2cto.com/uploadfile/Collfiles/20140208/2014020808292841.jpg alt = "\"/>
5. The Container View automatically points to another ViewController. Delete both the segue and the ViewController.
6. Right click (or ctrl + Left click) to drag a line from Container View to TableViewController, and then select Embed in the pop-up menu.
In this way, when you run the program, the normal ViewController will display the content in TableViewController, that is, the static cells are used in your own ViewController.
However, Embed segue is only valid after iOS 6. To be compatible with iOS 5, you can also use the following code to "embed" UITableViewController into a conventional ViewController:
-(Void) viewDidLoad
{
[SuperviewDidLoad];
Self. tableVC = [self. storyboardinstantiateViewControllerWithIdentifier: @ "DerivedTableViewController"];
[Self. containerViewaddSubview: _ tableVC. view];
}
Here, self is ViewController, self. tableVC is UITableViewController, AND self. containerView is subview of self.