Swipe to go back is disabled if the navigation bar is hidden

1.3k views Asked by At

My iOS 7 app uses UINavigationController with a hidden navigation bar. The top of my main screen includes a custom tab bar. I want to rely exclusively on the swipe to go back gesture, or the navigation buttons in the tab bar, without displaying the navigation bar and its back button.

What I'm observing is that setting self.navigationController.navigationBarHidden = YES hides the navigation bar and disables the gesture recognizer. Swiping left to right from the screen edge does nothing when I've descended a level in the navigation controller.

With this code:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    NSLog(@"%@", self.navigationController.interactivePopGestureRecognizer);
    NSLog(@"%@", self.navigationController.interactivePopGestureRecognizer.delegate);
}

I get:

2013-12-09 22:18:32.082 Redacted[496:60b] ; target= <(action=handleNavigationTransition:, target=<_UINavigationInteractiveTransition 0x146612f0>)>>

2013-12-09 22:18:36.795 Redacted[496:60b] <_UINavigationInteractiveTransition: 0x146612f0>

...which is the same regardless if I'm setting navigationBarHidden to YES or NO. So, the gesture recognizer, and its delegate, are both valid.

So why is this gesture recognizer not working when the navigation bar is hidden, and how do I fix that?

This is an iOS 7 app for iPhone/iPod touch screens.

0

There are 0 answers