Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 621
AsyncMoksha Avatar asked Oct 13 '14 02:10

AsyncMoksha


People also ask

How do I completely hide my Navigation bar?

Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.

How do I hide Navigation bar on Iphone?

You can find the Website View menu in what's called the Smart Search field at the top of the Safari interface. Launch the app and navigate to a website, then tap the "aA" icon in the upper left corner of the screen. Simply select Hide Toolbar from the dropdown menu, and the toolbar will shrink to show just the URL.

How do I hide the Navigation bar back button in Swiftui?

The . navigationBarBackButtonHidden(true) will hide the back button.


2 Answers

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!

like image 155
Ber.to Avatar answered Sep 20 '22 08:09

Ber.to


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

like image 20
AsyncMoksha Avatar answered Sep 19 '22 08:09

AsyncMoksha