[英]How to remove UISwipeGestureRecognizer From Navigation bar
My problem is related With UISwipeGestureRecognizer.I Add UISwipeGestureRecognizer for toggling the menu screen for the first screen. 我的问题与UISwipeGestureRecognizer有关。我添加了UISwipeGestureRecognizer用于切换第一个屏幕的菜单屏幕。 This is my code 这是我的代码
UISwipeGestureRecognizer *gestureRecognizernavle = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(toggleMenu)];
[gestureRecognizernavle setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[self.navigationController.navigationBar addGestureRecognizer:gestureRecognizernavle];
But the same function is calling while the swapping navigation bar on the next view. 但是,在下一个视图上交换导航栏时,正在调用相同的函数。 I put the following code for removing SwipeGestureRecognizer 我放置了以下代码以删除SwipeGestureRecognizer
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
But this code is not working. 但是此代码不起作用。 Could you please help me? 请你帮助我好吗?
Use the following code to remove the gesture recogniser from the navigation bar. 使用以下代码从导航栏中删除手势识别器。
while (self.navigationController.navigationBar.gestureRecognizers.count) {
[self.navigationController.navigationBar removeGestureRecognizer:[self.navigationController.navigationBar.gestureRecognizers objectAtIndex:0]];
}
It will remove all gesture recognisers from the navigation bar, you can put the conditions if you want to remove some some. 它将从导航栏中删除所有手势识别器,如果要删除某些手势,则可以放置条件。
Enjoy. 请享用。 :) :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.