How to Hide the "Back" Button in Uinavigationcontroller

How to hide the back button in UINavigationController?

I just found out the answer, in a controller use this:

[self.navigationItem setHidesBackButton:YES animated:YES];

And to restore it:

[self.navigationItem setHidesBackButton:NO animated:YES];

--

[UPDATE]

Swift 3.0:

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

UINavigationBar Hide back Button Text

In the interface builder, you can select the navigation item of the previous controller and change the Back Button string to what you'd like the back button to appear as. If you want it blank, for example, just put a space.

You can also change it with this line of code:

[self.navigationItem.backBarButtonItem setTitle:@"Title here"];

Or in Swift:

self.navigationItem.backBarButtonItem?.title = ""

Swift - How to hide back button in navigation item?

According to the documentation for UINavigationItem :

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

How can I hide the back arrow in the navigation bar's back button?

If you do ,

navigationController?.navigationBar.backIndicatorImage = nil
navigationController?.navigationBar.backIndicatorTransitionMaskImage = nil

or

navigationController?.navigationBar.backIndicatorImage = UIImage(named: "")
navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "")

Then by default iOS use < as default image.

To remove this image you need to add blank transparent image. I used sample from here and google image reference is here

Now reduce the image pixel size to (1,1) and add in your assets and use below code.

navigationController?.navigationBar.backIndicatorImage = UIImage(named: "Blank")
navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "Blank")

Here Blank is the same image name in my asset.

How to completely remove back button from navigation bar?

Note:Problem solved with just comment. But posting this as answer so that It will help someone else having same issue.

I too had same problem with navigationBarButtonItem while adding custom barButtonItem to navigationBar in storyboard. If you are also using storyboard then just set navigationBar tint color as clear color in navigationController. By setting clear color, that weird default navigation back button will not appear anymore.



Related Topics



Leave a reply



Submit