Giving thanks in advance, I would like to share the strange behaviour of UILongPressGestureRecognizer
.
UIView *v = [UIView alloc] initWithFrame:CGRectMake(0,0,20,20)];
UILongPressGestureRecognizer *longpressGesture1 = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
[v addGestureRecognizer:longpressGesture1];
and here the delegate to handle the gesture recogniser.
-(IBAction)tapped:(UILongPressGestureRecognizer *) gesture
{
switch ([gesture state]) {
case UIGestureRecognizerStateBegan:
{
NSLog(@"Long Tap detacted.");
}
break;
case UIGestureRecognizerStateChanged:
{
NSLog(@"UIGestureRecognizerStateChanged");
}
break;
case UIGestureRecognizerStateEnded:
{
NSLog(@"Long Tap ended.");
}
break;
}
}
This piece of code is working perfectly as expected in iOS 4 and 5, but in ios 6 with retina display when we perform the long tap, UIGestureRecognizerStateBegan
is being called twice for a single long tap resulting in a application crash.
Any help is greatly welcome.