Right now I have two view controllers. My problem is I don\'t know how to hide the back button after transitioning to the second view controller. Most references that I foun
Swift
// remove left buttons (in case you added some)
self.navigationItem.leftBarButtonItems = []
// hide the default back buttons
self.navigationItem.hidesBackButton = true
Put it in the viewDidLoad
method
navigationItem.hidesBackButton = true
In case you're using a UITabBarController
:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
self.tabBarController?.navigationItem.hidesBackButton = true
}
According to the documentation for UINavigationItem
:
self.navigationItem.setHidesBackButton(true, animated: true)
This is also found in the UINavigationController class documentation:
navigationItem.hidesBackButton = true
That worked for me in Swift 5 like a charm, just add it to your viewDidLoad()
self.navigationItem.setHidesBackButton(true, animated: true)