Graphics Reference
In-Depth Information
LISTING 13-5
Continued
- ( void )loadView
{
CGRect frame = [[UIScreen mainScreen] applicationFrame];
UIView *view = [[UIView alloc] initWithFrame :frame];
[view setBackgroundColor:[UIColor blackColor]];
CGRect box = CGRectMake(10, 10, 100, 100);
touchView = [[ TouchableView alloc] initWithFrame :box];
[view addSubview: touchView ];
[ touchView release];
[ self setView:view];
[view release];
}
In the TouchMeViewController we build only a single UIView and add the TouchableView
to it. No other implementation is required. That view is added to the UIWindow for the
application. To do this, we need to update the application delegate's header, as shown in
Listing 13-6.
LISTING 13-6
Application Delegate's Header
@class TouchMeViewController ;
@interface AppDelegate : NSObject <UIApplicationDelegate>
{
UIWindow * window ;
TouchMeViewController * viewController ;
}
@end
We have added a reference to the TouchMeViewController in the application delegate's
header so that we can release it at the appropriate time. With the header updated, we
next need to update the -applicationDidFinishLaunching: method to instantiate the
TouchMeViewController . When the TouchMeViewController is instantiated, add its asso-
ciated view to the window, as shown in Listing 13-7.
LISTING 13-7
Application Delegate's Implementation
- ( void )applicationDidFinishLaunching:(UIApplication *)application
{
window = [[UIWindow alloc] initWithFrame :[[UIScreen mainScreen] bounds]];
 
Search WWH ::




Custom Search