Search code examples
iosswiftxcodeback

I am unable to remove the back button from my Scrollview View Controller?


I wish to remove the back button from my view controller.
Remove book back button

My ViewController also has a scroll view attached to it.
So far I have added the following code to my viewDidLoad():

override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationItem.leftBarButtonItem = nil;
    self.navigationItem.hidesBackButton = true;
    self.navigationController?.navigationItem.backBarButtonItem?.isEnabled = false;
    self.navigationController!.interactivePopGestureRecognizer!.isEnabled = false;
    self.navigationItem.setHidesBackButton(true, animated:true);


    // Do any additional setup after loading the view.
}

However even after running the program with this added code, the back button still does not go away for some reason. I would like to know how I would go about removing the back button.
Much appreciated


Solution

  • Try this:

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