Pregunta

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.

¿Fue útil?

Solución

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).

Otros consejos

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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top