13

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 Answers 4

23

You have to try this:

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

hope it helps you.

Sign up to request clarification or add additional context in comments.

1 Comment

This worked for me using, I am using Version 7.0 beta 3 of Xcode
5

SWIFT 3

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

Comments

3

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

Comments

3

Try this,

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

Hope this helps. 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.