How to hide Navigation Bar without losing slide-back ability

Make sure to include:

self.navigationController.navigationBar.hidden = YES;

And:

self.navigationController.interactivePopGestureRecognizer.delegate = self;

And:

if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    }

It should appear like this:

- (void)viewWillAppear:(BOOL)animated {

    self.navigationController.navigationBar.hidden = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
            self.navigationController.interactivePopGestureRecognizer.enabled = YES;
        }
}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    return YES;
}

Found the solution:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    // hide nav bar
    [[self navigationController] setNavigationBarHidden:YES animated:YES];

    // enable slide-back
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
        self.navigationController.interactivePopGestureRecognizer.delegate = self;
    }
}


- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    return YES;
}

And in .h file, conform to UIGestureRecognizerDelegate


Use

self.navigationController.navigationBar.hidden = YES;

or add this line in viewWillAppear:

self.navigationController.interactivePopGestureRecognizer.delegate = self;

It seems the interaction is not effective, adding this line and make the view controller conforms to the UIGestureRecognizerDelegate protocol will make it work.


Tested with Swift 2 the solution of @gabbler, if you use

self.navigationController?.navigationBar.hidden = true

Swift 3.0

self.navigationController?.navigationBar.isHidden = true

instead of

self.navigationController?.navigationBarHidden = true

the swipe back gesture works like a charm!