For the past four hours, I have tried many Stack Overlow solutions but none have helped solve my problem.
Here it is,
your code seems to be fine,it should work i think.i used below code and its working fine for me.
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
longPress.delegate = (id)self;
longPress.minimumPressDuration=0.05;
imageView.userInteractionEnabled = YES;
[imageView addGestureRecognizer:longPress];
and its method,
- (IBAction)handleLongPress:(UILongPressGestureRecognizer *)sender {
NSLog(@"detected");
if (sender.state == UIGestureRecognizerStateEnded){
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"YES" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
}
Here i took imageView as subview of scrollview as u said