How to disable UISwipeGestureRecognizer when load a new view?

in my viewDidLoad I set

UISwipeGestureRecognizer *swipeRecognizerU = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeUpDetected:)]; swipeRecognizerU.direction = UISwipeGestureRecognizerDirectionUp; [self.view addGestureRecognizer:swipeRecognizerU];

when I load a new view through popup I need to disable that gesture

  • How do I create the current date (or any date) as an NSDate without hours, minutes and seconds?
  • Save image file to temp directory
  • How Do I add Pins (Annotations) with Xcode 6 (Swift)
  • Problems dismissing and representing UIImagePickerController camera iOS8.4
  • Capture picture from iOS camera
  • iOS Correctly stop AVCaptureSession
  • // show popup view
        MJDetailViewController *detailViewController = [[MJDetailViewController alloc] initWithNibName:@"MJDetailViewController" bundle:nil];
        [self presentPopupViewController:detailViewController animationType:MJPopupViewAnimationSlideBottomBottom];

    after popup view is dismissed, I need to set swipe gesture back.

    // hide popup view
        [self dismissPopupViewControllerWithanimationType:MJPopupViewAnimationSlideBottomBottom];

    how this can be done?

    2 Solutions Collect From Internet About “How to disable UISwipeGestureRecognizer when load a new view?”

    I think there is property named enabled for UIGestureRecognizer. Have you try this, it should be ok to disable your swipes:

    swipeGestureRecognizer.enabled = NO;

    You need set delegate at here.

    Ex :

    swipeleft=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeleft:)];
            swipeleft.delegate = self;
            [self.view addGestureRecognizer:swipeleft];

    Then add function

    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
        if ((touch.view == test[1]) || (touch.view == test[2]) || (touch.view == test[3])) {
            [gestureRecognizer setCancelsTouchesInView:YES];
            [swipeleft setCancelsTouchesInView:YES];
            [gestureRecognizer setEnabled:NO];
            [swipeleft setEnabled:NO];
            return NO;
            [gestureRecognizer setCancelsTouchesInView:NO];
            [swipeleft setCancelsTouchesInView:NO];
            [gestureRecognizer setEnabled:YES];
            [swipeleft setEnabled:YES];
        return YES;

    I think useful for you