Programmatically navigate to another view controller. Use the following example code to programmatically navigate to another view controller.
Swift 4
1 2 3 | let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) let nextViewController = storyBoard.instantiateViewController(withIdentifier: "nextView") as! NextViewController self.present(nextViewController, animated:true, completion:nil) |
Swift 3
1 2 3 4 | let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("nextView") as NextViewController self.presentViewController(nextViewController, animated:true, completion:nil) |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.