Graphics Programs Reference
In-Depth Information
TimeViewController *tvc = [[TimeViewController alloc] init];
[[self window] setRootViewController:hvc];
[[self window] setRootViewController:tvc];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
Build and run the application. As you might expect, you see the TimeViewControl-
ler 's view that you created in TimeViewController.xib . Now we need to con-
nect up the subviews.
Since TimeViewController is controlling this view hierarchy, it is responsible for
updating the label when the button is tapped. Thus, TimeViewController must be
the target of the UIButton and have a pointer to the UILabel . In TimeViewCon-
troller.h , declare an outlet and a method.
@interface TimeViewController : UIViewController
{
IBOutlet UILabel *timeLabel;
}
- (IBAction)showCurrentTime:(id)sender;
@end
Open TimeViewController.xib and connect the timeLabel outlet of File's
Owner (which we now know is the TimeViewController ) to the UILabel . Then
connect the UIButton to the File's Owner and select showCurrentTime: . These
connections are shown in Figure 7.11 .
Figure 7.11 TimeViewController XIB connections
 
 
Search WWH ::




Custom Search