0

I am running to a new viewcontroller and am trying to remove the back button completely. Here is what I am doing:

/* HIDE BACK BUTTON ON NAVIGATiON */
    self.navigationItem.hidesBackButton = YES;
    //<!-- Make sure navigation bar shows
    self.navigationController.navigationBar.hidden = NO; 

Now when I run this inside the ViewController viewdidload() of the current active controller it disabled the back button but the text back does not go away. Before that I use a [self performSegueWithIdentifier:@"pushToHomePage" sender:self]; to send it to the current ViewController that I am trying to remove the back button from.

Suggestions, thoughts?

David Biga
  • 2,763
  • 8
  • 38
  • 61
  • Where are you making this call? Have you checked to make sure navigationItem exists when this is called? I'm calling this from -viewDidLoad with success. As well in other places after the view has been presented. – Dave Batton Jan 13 '15 at 20:29
  • @DaveBatton I believe so. – David Biga Jan 13 '15 at 20:30
  • @DaveBatton I make this call within `- (void)viewDidLoad` of the newely pushed viewcontroller that I want to remove the back button from. – David Biga Jan 13 '15 at 20:31
  • If you don't want a back button, you probably shouldn't be using UINavigationController. Are you planning to disable the swipe-back gesture as well? Try using modals instead. http://stackoverflow.com/questions/14907518/modal-view-controllers-how-to-display-and-dismiss – Neal Ehardt Jan 13 '15 at 22:13

2 Answers2

0

For my experience, try to set to it to nil as well:

self.navigationItem.hidesBackButton = YES;
self.navigationItem.backBarButtonItem = nil;

Let me know ;)

Matteo Gobbi
  • 17,697
  • 3
  • 27
  • 41
0

Yes, the answer below by @MatteoGobbi is correct after validating in Xcode:

self.navigationItem.hidesBackButton = YES;
self.navigationItem.backBarButtonItem = nil;
Xiaojun
  • 833
  • 6
  • 4