Touchesbegan and touchesmoved functions not working on UIImageView

ios, iphone, objective-c, uiimageview

Solution

User interaction of `UIImageView` is by default NO. So you need to make it YES like this

self.userInteractionEnabled = YES;

Problem

I am having these 2 functions in my FYImageSequence.m file.I inherited the class from UIImageView ``` @interface FVImageSequence : UIImageView ``` I was able to connect this to my UIImageView in storyboard.But how to make the functions below working.Is there any connections that should be done. ``` -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ if(increment == 0) increment = 1; [super touchesBegan:touches withEvent:event]; UITouch *touch = [[event allTouches] anyObject]; CGPoint touchLocation = [touch locationInView:self]; previous = touchLocation.x; } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesMoved:touches withEvent:event]; UITouch *touch = [[event allTouches] anyObject]; CGPoint touchLocation = [touch locationInView:self]; int location = touchLocation.x; if(location < previous) current += increment; else current -= increment; previous = location; if(current > numberOfImages) current = 0; if(current < 0) current = numberOfImages; NSString *path = [NSString stringWithFormat:@"%@%d", prefix, current]; NSLog(@"%@", path); path = [[NSBundle mainBundle] pathForResource:path ofType:extension]; UIImage *img = [[UIImage alloc] initWithContentsOfFile:path]; [self setImage:img]; } ```

Original source