Ios UISweepGestureRecognitizerDirectionUp和uinavigationcontroller不工作?

Ios UISweepGestureRecognitizerDirectionUp和uinavigationcontroller不工作?,ios,objective-c,uinavigationcontroller,uiswipegesturerecognizer,Ios,Objective C,Uinavigationcontroller,Uiswipegesturerecognizer,我在上下使用UISweepGestureRecognitzerDirection。它工作正常,但当我添加UINavigationController时,滑动不工作。 这是我的密码 //In viewDidLoad UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)]; gesture.direction = UI

我在上下使用UISweepGestureRecognitzerDirection。它工作正常,但当我添加UINavigationController时,滑动不工作。 这是我的密码

//In viewDidLoad

UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)];
gesture.direction = UISwipeGestureRecognizerDirectionUp | UISwipeGestureRecognizerDirectionDown;
[self.view addGestureRecognizer:gesture];

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapViewController:)];
[self.view addGestureRecognizer:tap];


-(void)didSwipe:(UIGestureRecognizer *)gestureRecognizer {

CATransition *animation = [CATransition animation];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromTop];
[animation setDuration:1.25];
[animation setDelegate:self];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
CALayer *layer = [self.view layer];
[layer addAnimation:animation forKey:nil];
[self.view.window addSubview:self.view];

}

- (void) onTapViewController: (UIGestureRecognizer *) gesture {
}

- (IBAction)onClickBtn:(id)sender {

GotoNextViewController *gnvc = [self.storyboard instantiateViewControllerWithIdentifier:@"GNVC"];
[self.navigationController pushViewController:gnvc animated:NO];

}

这里当我点击按钮导航工作正常,但刷卡不工作

将您的
手势识别器
添加到
导航控制器
视图中,如下所示:

[self.navigationController.view addGestureRecognizer:gesture];
[self.navigationController.view addGestureRecognizer:tap];

将您的
手势识别器
添加到
导航控制器
视图中,如下所示:

[self.navigationController.view addGestureRecognizer:gesture];
[self.navigationController.view addGestureRecognizer:tap];

当我将导航添加到根视图控制器时,它对meAre不起作用,你的意思是在导航或其视图控制器上滑动你在主视图中使用UIScrollView吗?如果是,则无法识别向上/向下手势。@iOSDeveloper,由于UIScrollView附带的默认滚动功能,它无法工作,在滑动时会侦听滚动事件。如果禁用“已启用滚动”“UIScrollView的属性,它可以工作。这不是禁用滚动的解决方案。但是您可以使用左/右滑动而不是上/下滑动。您需要做什么,因为您的代码滑动与我一起工作当我将导航添加到根视图控制器时,它对meAre不起作用您的意思是在导航或其视图控制器上滑动您是否在主视图中使用UIScrollView?如果是,则无法识别向上/向下手势。@iOSDeveloper,由于UIScrollView附带的默认滚动功能,它无法工作,在滑动时会侦听滚动事件。如果禁用“已启用滚动”“UIScrollView的属性,它可以工作。这不是禁用滚动的解决方案。但是你可以使用左/右滑动而不是上/下。导航工作,但在根VC滑动中不是WOKING我正在使用故事板,所以将再次检查它谢谢你…让我们。导航工作,但在根VC滑动中不是WOKING我正在使用故事板,所以将再次检查它谢谢你…让我们。