Question

I have a viewController displaying images and text and the images are loaded and being animated every 15 seconds, I'd like to allow the user to swipe on the image view allowing him to change the image without waiting for the time to pass.

this is what I tried the images are loaded and animated but the swipe gesture doesn't work

self.imageView.animationImages = [self loadImages];
self.imageView.animationDuration = 15;
[self.imageView startAnimating];

swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeAction:)];
[swipeRight setDirection:(UISwipeGestureRecognizerDirectionRight)];
[self.imageView addGestureRecognizer:swipeRight];

this code is placed in the viewDidLoad method, I saw a solution adding the gesture to the view but I need it only on the imageView

Was it helpful?

Solution

I'm answering this in case someone else spends too much time on this one it appears i forgot to enable user interaction add this line:

self.imageView.userInteractionEnabled = YES; 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top