iphone - gesture not working on animated view

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-04-04T00:36:18Z Indexed on 2010/04/04 0:43 UTC
Read the original article Hit count: 340

Filed under:
|
|

I have this animated view and a gesture assigned to it...

[self.view setUserInteractionEnabled:YES];
UIImageView *sequence = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"frame0.png"]];
[sequence setUserInteractionEnabled:YES];
sequence.center = CGPointMake(centroX, centroY);
NSMutableArray *array = [[NSMutableArray alloc] init] ;

for (int i=0; i<30; i++) {
    UIImage *oneImage = [UIImage imageNamed:[NSString stringWithFormat:@"frame%d.png",i]];
       [array addObject:oneImage];
}



sequence.animationImages = array;
sequence.animationDuration = 1.0;
sequence.animationRepeatCount = 1;
[self.view addSubview:sequence];
[sequence release];
sequence.startAnimating;

sequence.image = [UIImage imageNamed:@"frame29.png"];

// doSomething never runs when I tap the image... why?
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self 
                                    action:@selector(doSomething)];
[singleTap setDelegate:self];
[singleTap setCancelsTouchesInView:NO];
[singleTap setDelaysTouchesEnded:NO];
[sequence addGestureRecognizer:singleTap];
[singleTap release];

The gesture is never called... why? I have no other gesture associated anywhere.

thanks for any help.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk