I am trying this code on UIScrollView but it’s not working. The NSLog is not appearing on my console. What’s wrong? its working fine when its not on UIScrollView.
- (void)viewDidLoad
{
[super viewDidLoad];
[self papers];
UIGestureRecognizer *recognizer = [[ UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
longPressGR = (UILongPressGestureRecognizer *)recognizer;
longPressGR.minimumPressDuration = 0.5;
[Image1 addGestureRecognizer:longPressGR];
}
-(void) handleLongPress:(UILongPressGestureRecognizer *)recognizer {
NSLog(@"Long Press");
}
You didn’t say what Image1 is. I’m guessing a UIImageView, in which case you need to make sure you do:
(Unlike most views, UIImageView has interaction disabled by default.)
(As an aside, it’s conventional in Objective-C to have your ivars and methods begin with lower-case letters; classes begin with upper-case.)