QueueOverFlow QueueOverFlow - 6 months ago 20
iOS Question

How to hide navigation bar back button

My question is simple, How to hide back button in navigation bar? I see similar question here in stack overflow but

self.navigationItem.hidesBackButton = YES;


not working for me. I am using below code because RootViewController is my Singleton class.

Thanks

i still use both in viewDidLoad but both are not working

[RootViewController sharedFirstViewController].navigationItem.hidesBackButton = YES;

[RootViewController sharedFirstViewController].navigationItem.backBarButtonItem=nil;

Answer

Try self.navigationItem.backBarButtonItem.hidden = YES; or self.navigationItem.backBarButtonItem = nil;

Place one of these either in viewWillAppear:, viewWillLoad or viewDidAppear: of the class you want to get rid of the back button in.