Question

I followed the session's demo of the 121 WWDC 2010 (Advanced Gesture Recognition) to find a way to have all behaviors (rotate, scale, translate) on an other class (TransformGestureReconizer) and all goes well and do this for the subviews:

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:baseView];
    subView1.userInteractionEnabled = YES;
    [self addTransformGestureToView:subView1];
}

Here is my problem : I would like to have an action when I double tap on a desired subview.

So If I add a :

- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer

I can't choose which view my action delivers (like changing the image on it) If I add on the main view:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

I can only handle the double tap on the main view, but not for the subviews and can only do it on the TransformGestureReconizer.h but then not choose the view tapped ( I think because subclass of UIGestureRecognizer).

Was it helpful?

Solution

I found a solution :

    UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
[doubleTap setNumberOfTapsRequired:2];
[self addTransformGestureToView:subView1];
[self.subView1 addGestureRecognizer:doubleTap];
[doubleTap release];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top