sandy
sandy

Reputation: 2157

Hide back button of navigation bar in Story board iOS

I would like to hide back button of navigation bar which is a part of Story board, I have tried different following code snippets in detail view button nothing seems to work for me.

self.navigationItem.hidesBackButton = YES;

self.navigationItem.backBarButtonItem=nil;

PS: I am also having tab bar along with navigation bar in my story board

Upvotes: 6

Views: 5610

Answers (5)

user2239333
user2239333

Reputation:

Add this line in the viewDidLoad of your ViewController where you would like to hide the back bar button:

[self.navigationItem setHidesBackButton:YES];

Tested successfully in a storyboard project.

Upvotes: 9

user216661
user216661

Reputation: 323

If you have added your own button to the navigationController and want to hide that as well (such as while editing text), its a two line process like this:

myViewController.navigationItem.leftBarButtonItem = nil;
myViewController.navigationItem.hidesBackButton=YES;

Upvotes: 1

Meera
Meera

Reputation: 1031

Try this

self.navigationItem.hidesBackButton= YES;

Upvotes: 1

Geek
Geek

Reputation: 8320

Its too late answer but may help others.
To hide back button you can do this :

self.navigationController.navigationItem.leftBarButtonItem.hidden = YES;

You can also try with :

self.navigationItem.leftBarButtonItem.hidden = YES;

This actually hides left BarButton and back button is on left side, too, unless you change programmatically.

Upvotes: -1

ader
ader

Reputation: 5393

You can hide the entire navigationbar as follows:

self.navigationController.navigationBar.hidden = YES;

then in your storyboard you can add a navigation bar to your view controller.

The result is what you want but maybe users will be confused as to why they can't go back...

Upvotes: -1

Related Questions