문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top