在进行 interactivePopGestureRecognizer 转换时禁用滚动

Disable scrolling when interactivePopGestureRecognizer transition is taking place

我已经实现了 interactivePopGestureRecognizer。它过渡到上一页。但问题是,当转换发生时,如果当前视图控制器中有 UIScrollView,它就会开始滚动。有什么办法可以预防吗?

我已经在我的 RootViewcontroller 中添加了手势:

   self.appNavController = [[UINavigationController alloc] initWithRootViewController:controller];
    self.appNavController.interactivePopGestureRecognizer.enabled = YES;
    self.appNavController.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self;
    [self.appNavController setNavigationBarHidden:YES];

我把这个叫做:

-(void)viewDidAppear:(BOOL)animated{

    [super viewDidAppear:animated];

    APP_DELEGATE.rootViewController.appNavController.interactivePopGestureRecognizer.enabled = NO;

}

-(void)viewWillDisappear:(BOOL)animated{

    [super viewWillDisappear:animated];

    APP_DELEGATE.rootViewController.appNavController.interactivePopGestureRecognizer.enabled = YES;

}

我找到了解决方案。在正在滑动的视图控制器中,我添加了以下内容:

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];

    self.scrollView.scrollEnabled = YES;
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];

    self.scrollView.scrollEnabled = NO;
}

效果非常好。