Push to ViewController without back button

2020-05-23 09:01发布

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];

7条回答
▲ chillily
2楼-- · 2020-05-23 09:51

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

Objective-C

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

Swift

navigationController.setViewControllers([controller], animated:true)
查看更多
登录 后发表回答