timgcarlson timgcarlson - 1 year ago 160
Objective-C Question

Remove view controller from navigation stack after push segue (using Storyboard segues)

My app is contained in a

. The root view controller A is essentially a login view, where the user will enter credentials and upon success will present the profile view controller B via a push segue. Right now the user gets the back button on the nav bar of B to navigate back to A. I want B to now be the root view controller on the navigation stack, effectively preventing the user from ever getting back to A until a new app launch.

What is the correct way to handle this while still using a push segue? Should I perform the presentation of B without a segue and effectively start B off with a new navigation controller?

Answer Source

Just replace the rootViewController of your UIWindow. controllerA and controllerB can be any Viewcontroller-Class you want.

You could use a simple UITableViewController for the Loginpage and then replace the rootViewController of your UIWindow with a UINavigationController holding controllerB

[UIView transitionFromView:controllerA.view
                       options:(UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionTransitionCrossDissolve)
                    completion:^(BOOL finished){
                        delegate.window.rootViewController = controllerB;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download