We can specify images array for a UIImageview
, and it will animate the images very nicely. I have subclassed the UIImageView
class.
Now when the user clicks the image, I capture the tap gesture but the problem is how do I know which image in the animationImages was clicked?
- (void)setup
{
self.animationImages = self.bannerImagesArray;
self.animationDuration = 3.0f;
self.animationRepeatCount = 0;
[self startAnimating];
self.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageClicked)];
[self addGestureRecognizer:tapGesture];
}
- (void)imageClicked
{
NSLog(@"Image clicked");
// How do i detect which image was clicked here
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…