How to enable back/left swipe gesture in UINavigationController after setting leftBarButtonItem?

The Solution to How to enable back/left swipe gesture in UINavigationController after setting leftBarButtonItem? is


First set delegate in viewDidLoad:

self.navigationController.interactivePopGestureRecognizer.delegate = self;

And then disable gesture when pushing:

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    [super pushViewController:viewController animated:animated];
    self.interactivePopGestureRecognizer.enabled = NO;
}

And enable in viewDidDisappear:

self.navigationController.interactivePopGestureRecognizer.enabled = YES;

Also, add UINavigationControllerDelegate to your view controller.

~ Answered on 2016-01-22 09:19:20


Most Viewed Questions: