Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push to ViewController without back button

I am developing an iOS app which contains login/authentication functionality - basically first time a user logins, in they need to enter relevant login details - then they are passed to main app screens - subsequent visits to the app they will be automatically authenticated.

All above works fine - the issue I have is with the Navigation bar - it appears in the main screen in the main part of the app with a back button - I don't want this to be displayed as they should not be able to return to the login screen once authenticated. I guess it's using the root navigation controller which explains the logic, but is there a way to ignore the navigation controller of the login section so the back button is not displayed in the main app.

Below is a screenshot of the structure to help my explanation - left hand group of screens are the login process right hand is the main app structure.

enter image description here

The code used to switch screens is as follows -

SWRevealViewController *swRevealController = (SWRevealViewController *)navVC;
swRevealController.managedObjectContext = self.managedObjectContext;
[self.navigationController pushViewController:controller animated:YES];
like image 863
Dancer Avatar asked Mar 10 '14 13:03

Dancer


People also ask

How do I go back without navigation bar?

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 to hide back button on navigation bar in iOS?

To hide the back button on navigation bar we'll have to either set the navigation button as nil and then hide it or hide it directly. Let's create a project, add 2 view controller and Embed them in navigation controller.


1 Answers

Don't push view controller. Create new hierarchy with:

Objective-C

[self.navigationController setViewControllers:@[controller] animated:YES];

Swift

navigationController.setViewControllers([controller], animated:true)
like image 97
Cy-4AH Avatar answered Sep 19 '22 23:09

Cy-4AH