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:
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.
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.
You can do: [self. navigationItem setHidesBackButton:YES]; In your second view controller (the one you want to hide the button in).
viewController.navigationItem.hidesBackButton = YES;
This works perfectly!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With