Frage

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.

War es hilfreich?

Lösung

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

Andere Tipps

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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top