Senju
Senju

Reputation: 1035

UILongGestureRecognizer not firing if slight movement by user

Currently I'm using UILongPressGestureRecognizer to add a function to a UIButton and then calling setMinimumPressDuration:1 to call the function after the button is pressed down for 1 second. A problem I found, however, is that if the user so much as moves his finger half a centimeter while touched down over the button, it will not call the function.

In other words, the user has to basically stay touched down on one pixel for one second in order for the trigger to activate, even though the button is 100x100 pixels. This is pretty easy with a mouse, but becomes a problem on a physical device. Is there a way to fix this? I was thinking creating a trigger so that if a button has an alpha value < 1 for 1 sec it would call the function (when touched down the UIButton's alpha value is 0.75). How would I go about accomplishing that if there is no other way to repair the UILongGestureRecognizer problem.

Posting on a mobile device. Will fix any formatting problems/add code if needed as soon as I can get to my computer. Thanks.

Upvotes: 2

Views: 127

Answers (1)

Gonzo
Gonzo

Reputation: 1553

UILongGestureRecognizer has a property called allowableMovement that's described on the documentation as "The maximum movement of the fingers on the view before the gesture fails."

Upvotes: 3

Related Questions