You need to implement the UIGestureRecognizerDelegate method:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;
And add your controller as a delegate of gesture recognizers. Then, when two gesture recognizers respond to the gesture, this method will be called, and here you can implement the logic that you want for your application.
In the controller interface declaration, you must enter:
@interface testcViewController () <UIGestureRecognizerDelegate>
Then, when creating the gesture recognizer:
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe)]; swipe.direction = UISwipeGestureRecognizerDirectionDown; swipe.delegate = self; [self.view addGestureRecognizer:swipe];
And then finally you add this method to the controller:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { BOOL shouldInteract = NO;
EDIT You can also implement
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer;
And here, determine if you have already submitted sub-items, and block any gesture you want.
source share