Graphics Programs Reference
In-Depth Information
Another UIViewController
Now let's turn to HypnoTime 's second UIViewController subclass. Create a new
NSObject subclass and name it TimeViewController .
In TimeViewController.h , change the superclass to UIViewController .
@interface TimeViewController : NSObject
@interface TimeViewController : UIViewController
A TimeViewController 's screen will show a UILabel and a UIButton that up-
dates that label to the current time. Thus, the TimeViewController 's view will be a
blank, full-screen UIView that has two subviews - the button and label ( Figure 7.5 ).
Figure 7.5 TimeViewController's view hierarchy
When creating HypnosisViewController 's view hierarchy, you did so program-
matically: in loadView , you instantiated HypnosisView and set it as the view . This
view did not have any subviews.
TimeViewController 's view will have two subviews. When a view controller's
view has subviews, it is best to create and load its view hierarchy in a XIB file instead of
overriding loadView . Creating a view programmatically or from a XIB doesn't make
any difference once the application is running; a XIB file is just easier when you need to
lay out multiple view objects.
Create a new XIB file by selecting File + New + New File... . From the iOS section, select
User Interface and then choose the Empty XIB template ( Figure 7.6 ). On the next pane,
select iPhone from the pop-up menu.
 
Search WWH ::




Custom Search