Comment faire un superview bouton d'interception des événements tactiles?

Dire que j'ai ce code:

#import <UIKit/UIKit.h>

@interface MyView : UIView
@end
@implementation MyView

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    //How can I get this to show up even when the button is touched?
    NSLog(@"%@", [touches anyObject]);
}

@end

@interface TestViewAppDelegate : NSObject <UIApplicationDelegate>
{
    UIWindow *window;
}

@end

@implementation TestViewAppDelegate

- (void)applicationDidFinishLaunching:(UIApplication *)application
{
    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    MyView *view = [[MyView alloc] initWithFrame:[window frame]];
    [view setBackgroundColor:[UIColor whiteColor]];

    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button setTitle:@"Hiya!" forState:UIControlStateNormal];
    [button setFrame:CGRectMake(100.0, 100.0, 200.0, 200.0)];
    [view addSubview:button];

    [window addSubview:view];
    [window makeKeyAndVisible];
}


- (void)dealloc
{
    [window release];
    [super dealloc];
}

@end

Est-il possible d'intercepter les événements tactiles envoyés au bouton? Ce que j'aimerais éventuellement faire est de faire une sous-classe UIView que va dire son point de vue contrôleur (ou de son délégué, selon) lorsqu'il détecte un balayage, de sorte qu'il peut "pousser" le côté-vue-contrôleur sur la pile (similaire à l'écran d'accueil iPhone). J'ai pensé que c'était la première étape, mais je suis ouvert aux suggestions si j'aborde cette question de façon incorrecte.

InformationsquelleAutor Michael | 2009-08-15