Question

I have a UINavigationController that has a UIPanGestureRecognizer:

MyNavController.m
...

menuGesture.delegate = self;
[self.view addGestureRecognizer:menuGesture];

It works great, but I need to ignore that UIPanGestureRecognizer in one of my topViewControllers. I tried self.view.gestureRecognizers = nil, but it didn't work.

Was it helpful?

Solution

If you need to enable/disable some gesture recognizers that you have added in your controllers, one approach would be exposing that gesture recogniser through a property and then enable/disable it at will:

@property(nonatomic, assign/weak) UIPanGestureRecognizer* myGestureRecognizer;

...

[(MyNavController*)myController.navigationController myGestureRecognizer].enabled = NO;

(of course, your menuGesture would be stored in myGestureRecognizer for this to work).

OTHER TIPS

You'll want to subscribe to the UIGestureRecognizerDelegate and then determine if the gesture should be allowed in gestureRecognizer:shouldReceiveTouch:

try like this :UINavigationController has a method called

- (void)removeGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top