Created
April 28, 2018 11:43
-
-
Save anitaa1990/931548eb906725f611a97bd55f3ab2fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func handleLoginAction(_ sender: Any) { | |
/* | |
* This example is when we want to pop current view controller & remove it from navigation backstack | |
* before adding a new view controller to the stack | |
*/ | |
/* Step 1: Instantiate the new View controller. In this case: ViewControllerC */ | |
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) | |
let viewControllerC = storyBoard.instantiateViewControllerWithIdentifier("ViewControllerC") as! ViewControllerC | |
/* Step 2: Get the list of view controllers from the navigationController */ | |
var vcArray = self.navigationController?.viewControllers | |
/* Step 3: Remove the last view controller i.e. ViewControllerB from the stack */ | |
vcArray!.removeLast() | |
/* Step 4: Append the new view controller to the navigation stack */ | |
vcArray!.append(viewControllerC) | |
/* Step 5: Set the stack of view controllers to the navigationController */ | |
self.navigationController?.setViewControllers(vcArray!, animated: true) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment