Game Development Reference
In-Depth Information
Add a UIViewController to a XIB
There is one last item we need to add to the XIB file before we are done adding items. We
need to add a
UIViewController
that is responsible for the subviews that will be displayed in
the holder views we just added. The
UIViewController
we are going to add will be of the class
RockPaperScissorsController
, as defined earlier in this chapter. Figure
2-16
shows the XIB file with
a new
UIViewController
added.
Figure 2-16.
RockPaperScissorsController added to XIB file
In Figure
2-16
, we see that a View Controller was dragged from the library (A) to the Objects
section (B) and was set to be the class
RockPaperScissorsController
(C). In this way, when this
XIB file is instantiated, an instance of
RockPaperScissorsController
will be created as well. This
raises the question: how do we access the items within a XIB file programmatically? The answer
lies in creating
IBOutlets
, as the next section discusses.