Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Back Button in UINavigationBar Hide Problem

When I use this: [self.navigationItem setHidesBackButton:YES animated:NO]; to hide the back button in my navigationBar, my title doesn't get centered. It prints like the button is still there.

does anyone know why this happens, and how to fix it?

EDIT:

My program is like so: my rootViewController is a navigation controller, and I set that so the navigation bar is hidden. Then I push to another UIViewController, which I make the navigation bar appear again, but make the back button disappear.

I tried the setting self.navigationItem.backBarButtonItem = nil;, but it didn't make the backbutton disappear.

Here's some pictures for reference:

Picture with back buttonPicture without

like image 513
jylee Avatar asked Aug 05 '11 15:08

jylee


People also ask

How to hide back button navigation?

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 to hide navigation back button in iOS Swift?

Basic Swift Code for iOS Apps To hide the back button on navigation bar we'll have to either set the navigation button as nil and then hide it or hide it directly.

How can remove back button in iOS?

You can do: [self. navigationItem setHidesBackButton:YES]; In your second view controller (the one you want to hide the button in).


1 Answers

viewController.navigationItem.hidesBackButton = YES;

This works perfectly!

like image 67
Fourj Avatar answered Oct 08 '22 18:10

Fourj