12
votes

in the Storyboard (Xcode 6, iOS 8 and swift) i have embedded a TableViewController in a Navigation Controller.

From the object library, i have drag & drop a Bar Button Item as the back button and it show an icon image: when i click that button i show a setting view.

How can i hide that button? In the viewDidLoad() i've tried:

self.navigationItem.hidesBackButton = true;

The code is executed (i've tried with the debugger) but the button is always visible.

4

4 Answers

22
votes

You have to try this:

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

hope it helps you.

5
votes

SWIFT 3

self.navigationItem.setRightBarButton(nil, animated: true)
3
votes

If the bar button item is on the right side of the navigation bar you have to set

self.navigationItem.rightBarButtonItems = []

if the bar button item in question is on the left side do the same, it will remove the bar button items from the navigation item

3
votes

Try this,

self.navigationItem.setLeftBarButtonItem(nil, animated: true)

Hope this helps.