forkingdog / FDFullscreenPopGesture

A UINavigationController's category to enable fullscreen pop gesture with iOS7+ system style.
MIT License
5.9k stars 1.15k forks source link

使用setViewControllers:animated:,block不会调用 #170

Open mikibw opened 6 years ago

mikibw commented 6 years ago

使用NavigationController的setViewControllers:animated:方法,block不会调用

sunsx9316 commented 6 years ago

这个问题我也碰到了 比较粗暴的解决方法是替换 setViewControllers:animated: 这个方法 里面的代码照搬 - (void)fd_pushViewController:(UIViewController *)viewController animated:(BOOL)animated

- (void)fd_setViewControllers:(NSArray<UIViewController *> *)viewControllers animated:(BOOL)animated {
    if (![self.interactivePopGestureRecognizer.view.gestureRecognizers containsObject:self.fd_fullscreenPopGestureRecognizer]) {

        // Add our own gesture recognizer to where the onboard screen edge pan gesture recognizer is attached to.
        [self.interactivePopGestureRecognizer.view addGestureRecognizer:self.fd_fullscreenPopGestureRecognizer];

        // Forward the gesture events to the private handler of the onboard gesture recognizer.
        NSArray *internalTargets = [self.interactivePopGestureRecognizer valueForKey:@"targets"];
        id internalTarget = [internalTargets.firstObject valueForKey:@"target"];
        SEL internalAction = NSSelectorFromString(@"handleNavigationTransition:");
        self.fd_fullscreenPopGestureRecognizer.delegate = self.fd_popGestureRecognizerDelegate;
        [self.fd_fullscreenPopGestureRecognizer addTarget:internalTarget action:internalAction];

        // Disable the onboard gesture recognizer.
        self.interactivePopGestureRecognizer.enabled = NO;
    }

    [self fd_setViewControllers:viewControllers animated:animated];
}