I have problems with a long press gesture here. I looked around and found some post related to my problems, but still no luck.
I have a long gesture for the presentation for the presentation, and I want to show the warning view when the gesture is a trigger, but somehow the trigger was called twice when the warning view is displayed, I check the status of the gestures but still no luck. Here is the code:
Source:
UILongPressGestureRecognizer *longTap = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
[longTap setMinimumPressDuration:1];
[self addGestureRecognizer:longTap];
- (IBAction)handleTapGesture:(UIPanGestureRecognizer*)sender {
if (sender.state == UIGestureRecognizerStateChanged) {
NSLog(@"Change");
} else if (sender.state == UIGestureRecognizerStateEnded) {
NSLog(@"Ended");
}
else {
NSLog(@"Begin");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Long pressed" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
}
The strangest thing is, if I delete [warning show], everything will go as expected, the trigger gesture only once. Does anyone have an explanation? Thanks in advance.
source
share