I have an object of image type which I am moving using UIPanGestureRecognizer, and I need to stop recognizing the UIPanGestureRecognizer when the object reaches a certain frame.
When you need to stop your UIPanGestureRecognizer from recognizing gesture, you just put this code line (as jbat100 said) in -(void)move:(UIPanGestureRecognizer *)gestureRecognizer
:
gestureRecognizer.enabled = NO;
after this line your gestureRecognizer state set as "UIGestureRecognizerStateCancelled"
then just add couple lines to your -(void)move:(UIPanGestureRecognizer *)gestureRecognizer
function:
if ([gestureRecognizer state] == UIGestureRecognizerStateCancelled) {
gestureRecognizer.enabled = YES;
}
and you'll be able to work with your gesture recognizer
EDIT:
Here's code snippet:
- (void)move:(UIPanGestureRecognizer *)gestureRecognizer {
BOOL cancelPanGesture = YES;
if (cancelPanGesture) {
/*
After this line gesture recognizer will be disabled, state will be UIGestureRecognizerStateCancelled
and this method (move:) will fire one more time.
*/
gestureRecognizer.enabled = NO;
}
if (gestureRecognizer.state == UIGestureRecognizerStateCancelled) {
gestureRecognizer.enabled = YES;
}
}