Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How hide back bar button in navigation controller with swift

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.

like image 751
Tom Avatar asked Jan 25 '15 17:01

Tom


People also ask

How can remove back button in iOS?

You can do: [self. navigationItem setHidesBackButton:YES]; In your second view controller (the one you want to hide the button in).

How do I hide items in navigation bar?

Go to your Navbar settings and find the navigation item you want to hide for a particular page. Click to edit and assign it a classname. You could assign it something like "hide-navigation-item."

How do I get rid of the back button in Swiftui?

Use navigationBarBackButtonHidden(_:) to hide the back button for this view.


2 Answers

You have to try this:

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

hope it helps you.

like image 193
lojals Avatar answered Oct 17 '22 16:10

lojals


SWIFT 3

self.navigationItem.setRightBarButton(nil, animated: true)
like image 5
Ahmed Safadi Avatar answered Oct 17 '22 16:10

Ahmed Safadi