I have a UIView where before I use UILongPressGestureRecognizer and then I use UIPanGestureRecognizer. To UIPanGestureRecognizer I get a message about the pressure of UILongPressGestureRecognizer but my app doesn’t take the boolean, this is always false even if I impose true. How can I do?
-(IBAction)longGesture:(UILongPressGestureRecognizer *)gestureRecognizer{
if(fromRiga ==0){
if ([gestureRecognizer state]==UIGestureRecognizerStateBegan){
self.inLongPress = YES;
self.view.backgroundColor =[UIColor darkGrayColor];
gestureRecognizer.allowableMovement=200;
}else if([gestureRecognizer state]==UIGestureRecognizerStateEnded){
self.inLongPress = NO;
}
}
- (IBAction)panGesture:(UIPanGestureRecognizer *)gestureRecognizer
{
NSLog(@"inLongPress is %@", self.inLongPress ? @"YES": @"NO");
}
thanks in advance
Pan recognizer triggers immediately when you touch the view and checks the movement since that moment. Long press recognizer triggers always much later then pan recognizer (after the long period ends). I suspect that the
panGestureis always called beforelongGesture. Maybe the pan recognizer is cancelling long press recognizer entirely.You should check what happens by adding more
NSLogstatements.