Graphics Programs Reference
In-Depth Information
UITableViewControllers in Storyboards
When using a UITableViewController , you typically implement the appropriate
data source methods to return the content of each cell. This makes sense when you have
dynamic content - like a list of BNRItem s that may change - but it is a lot of work when
you have a table whose content never changes. Storyboards allow you to add static content
to a table view without having to implement the data source methods.
To see how easy this is, we're going to add a UITableViewController to the story-
board and give it static content. (Depending on a number of factors, the root view control-
ler of the UINavigationController may already be a UITableViewControl-
ler . If this is the case in your storyboard, go through the following steps anyway for the
practice.)
First, you need to delete the current root view controller of the navigation controller. In
Storytime.storyboard , select the black bar that represents the UIViewControl-
ler that is the root view controller. Then press the Delete key. That view controller is now
gone, and the navigation controller no longer has a root view controller.
Next, drag a UITableViewController from the library onto the canvas. To set this
table view controller as the root view controller of the navigation controller, Control-drag
from the navigation controller's view to the table view controller. Let go, and from the
black panel that appears, select Relationship - rootViewController ( Figure 24.7 ).
Figure 24.7 Setting a relationship
This establishes the UITableViewController as the root view controller of the
UINavigationController . There will now be an arrow from the navigation control-
ler to the table view controller. In the middle of this arrow is an icon that represents the
type of relationship between the two view controllers ( Figure 24.8 ).
Figure 24.8 UINavigationController and UITableViewController
 
 
Search WWH ::




Custom Search