Domanda

it means user can't pan and pinch simultaneously and pinch gesture stops pan one.

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {

    return YES;
}

This code is not working for me because it makes these gestures working simultaneously.

By default if I don't use this code then pan gesture stops pinch one but I need the opposite thing.

Updated

@interface SomeClass : UIViewController <UIGestureRecognizerDelegate>

...

@end

@implementation SomeClass

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {

        return YES;
    }

@end
È stato utile?

Soluzione 2

solved by editing pan gesture handler:

- (IBAction)panGRUsed:(id)sender {

    UIPanGestureRecognizer *gr = (UIPanGestureRecognizer *)sender;
    if (gr.numberOfTouches > 1) {

        [gr setTranslation:CGPointZero inView:self.view];
    } else {

        ...
    }
}

Altri suggerimenti

You can create dependencies between recognizers using the requireGestureRecognizerToFail: method so that one gesture will only become eligible to begin when another has failed.

Depending on exactly what you need you may have to subclass and create your own gestures so that you can control how and when they begin and fail.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top