KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
The allowableMovement property in my UILongPressGestureRecognizer seems to be ignored. I created a new project (Xcode 4.5.1, iOS 6) using the Single View Application template and added a Long Press Gesture Recognizer to the view. There's an outlet wired up and an action. Here's the code for the action method: - (IBAction)longPress:(UILongPressGestureRecognizer *)sender { if (sender.state == UIGestureRecognizerStatePossible) NSLog(@"possible"); if (sender.state == UIGestureRecognizerStateBegan) NSLog(@"began"); if (sender.state == UIGestureRecognizerStateChanged) NSLog(@"changed"); if (sender.state == UIGestureRecognizerStateRecognized) NSLog(@"recognized"); if (sender.state == UIGestureRecognizerStateCancelled) NSLog(@"cancelled"); if (sender.state == UIGestureRecognizerStateFailed) NSLog(@"failed"); CGPoint locationInView = [sender locationInView:self.view]; NSLog(@"long press: allowableMovement= %f, x= %f, y= %f", sender.allowableMovement, locationInView.x, locationInView.y); } If I press long enough and let go I get this in the log: 2012-10-30 20:24:41.449 Long Press[1078:907] began 2012-10-30 20:24:41.455 Long Press[1078:907] long press: allowableMovement= 10.000000, x= 210.500000, y= 99.500000 2012-10-30 20:24:42.880 Long Press[1078:907] recognized 2012-10-30 20:24:42.882 Long Press[1078:907] long press: allowableMovement= 10.000000, x= 208.500000, y= 96.000000 This is what I would expect. But no matter what I set allowableMovement to (positive, negative, big, small), once the state is UIGestureRecognizerStateBegan , I can drag my finger all over the screen. The state changes to UIGestureRecognizerStateChanged and there are frequent updates and locationInView continues to accurately track. When I let go I get the UIGestureRecognizerStateRecognized</code
Tags (comma-separated)
Save Edits
Cancel