Hide navigation back button on iOS 11.4

67 Views Asked by At

To hide the back button on iOS, we generally write:

self.navigationController?.navigationBar.topItem?.backBarButtonItem = nil

or

self.navigationController?.navigationItem.leftBarButtonItem = nil

or

self.navigationController?.navigationItem.backBarButtonItem = nil

or

self.navigationItem.setHidesBackButton(true, animated: true)

None of the above statements works in my case i.e. iOS 11.4.

Is this any known bug in iOS 11.4 version or I am doing anything wrong?

3

There are 3 best solutions below

0
On

Try self.navigationController?.navigationBar.topItem?.leftBarButtonItem = nil

It works for me in iOS 11.4 and iOS 13.1

0
On

First make a Outlet like this @IBOutlet var naviBar: UINavigationItem!

Then try this self.naviBar.hidesBackButton = true

Worked for me...!

0
On

Try this

 self.navigationController?.navigationItem.hidesBackButton = true