I want to hide the back button when transitioning from one view to another. I read the questions regarding this problem and every answer was "use hidesBackButton
". The problem with this is:
when I put it in viewDidLoad/viewWillAppear the back button arrow hides but the string "Back" doesn't.
when I put it in viewDidAppear the back button disappears but it visible to the user
How can I fix this?
Edit:
Here is how you can replicate this problem(or bug?)
Make a new Tabbed application with Swift in Xcode. In the FirstViewController.swift use performSegueWithIdentifier to navigate to the second view controller. In the SecondViewController.swift hide the navigation bar back button using hidesBackButton and you will see what the problem is.
While you are pushing 2nd controller from 1st controller, put self. navigationItem. title = "" in viewWillDisappear of 1st controller. It hides back button title from 2nd controller.
Way 1: 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.
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. Let's create a project, add 2 view controller and Embed them in navigation controller.
To hide the back button with the latest Swift:
self.navigationItem.setHidesBackButton(true, animated: false)
Try adding this:
let backButton = UIBarButtonItem(title: "", style: .Plain, target: navigationController, action: nil)
navigationItem.leftBarButtonItem = backButton
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