Nouveau pour l'iPhone SDK: touchesBegan pas appelé

J'ai créé un très très basic application iPhone avec Fichier/Nouveau Projet/View-Based application.
Pas de PLUME fichier.

Voici mon appDelegate

.h

    @interface MyAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    MyViewController *viewController;
}

.m

    - (void)applicationDidFinishLaunching:(UIApplication *)application {    

    //Override point for customization after app launch    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
}

Et voici ma méthode loadView dans mon contrôleur

 - (void)loadView {
 CGRect mainFrame = [[UIScreen mainScreen] applicationFrame];
 UIView *contentView = [[UIView alloc] initWithFrame:mainFrame];
 contentView.backgroundColor = [UIColor redColor];
 self.view = contentView;
 [contentView release];
}

Maintenant, pour rattraper le touchesBegan événement, j'ai créé une nouvelle sous-classe de UIView:

.h

@interface TouchView : UIView {
}

.m

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
 NSLog(@"Touch detected");

}

et modifié la deuxième ligne dans mon loadView dans cette :

 TouchView *contentView = [[UIView alloc] initWithFrame:mainFrame];

Pourquoi est touchesBegan jamais appelé?

InformationsquelleAutor Coriolan | 2009-10-26