Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS how to remove back button?

I have an application with a navigation bar that pushes to a login screen view controller and then pushes to a main menu. Is there any way I can remove the back button off the main menu, so the user is unable to go back to the login screen?

Thanks!

EDIT: Using Xcode 4.3 and doing all the leg work programmatically.

like image 882
jbearden Avatar asked Feb 29 '12 12:02

jbearden


People also ask

How do I get rid of the back button on my iPhone?

Yes, the back button can be disabled. Please navigate to Advanced Website Kiosk Settings–>Navigation–>Disable back button. Kindly enable this restriction to disallow the usage of the back button on the iOS device.

How do I make my back button invisible?

Way 1: Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.

How do I hide the back button in SwiftUI?

The . navigationBarBackButtonHidden(true) will hide the back button.


2 Answers

You can do:

[self.navigationItem setHidesBackButton:YES]; 

In your second view controller (the one you want to hide the button in).

like image 69
Peter Sarnowski Avatar answered Oct 11 '22 15:10

Peter Sarnowski


Peters answer is correct, although I think the better question is why? In a schema like yours where you are wanting to login a user, instead of using a Pushed VC, present a Modal VC and use a delegate method to get back the userinfo that was obtained in the Login process. I can post a complete code example if you need it, but it sounds like you have the details worked out with your login process. Just use:

presentModalViewController 

instead of:

pushViewController 

That way, you don't have to worry about the navigation stack and doing something that isn't really in-line with the user interface guidelines.

like image 38
LJ Wilson Avatar answered Oct 11 '22 15:10

LJ Wilson