How to hide Navigation Bar without losing slide-back ability
ios, objective-c, xcode
Solution
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
Problem
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?