Zinan Xing Zinan Xing - 1 year ago 114
iOS Question

How to hide Navigation Bar without losing slide-back ability

I have a UITableView and it has a nav bar(got from UINavigationViewController), it's able to go back by sliding back using a finger.

I tried to hide the nav bar but keep the slide-back ability, code:

- (void)viewWillAppear:(BOOL)animated {
[[self navigationController] setNavigationBarHidden:YES animated:YES];

This successfully hid the nav bar, however, I can no longer slide back to the last screen either.

Is there any way to hide the nav bar but keep the slide-back ability?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download