How can I manually switch between UIViewControllers in storyboard?

I’m guessing that you are using a UINavigationController. Then you can simply do like this:

LoginViewController *controller = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:YES];

Update:

If you are using a UIStoryboard, you can set the identifier of your new viewcontroller, and then push it onto your navigationController. To set the identifier, choose your view, open the Attributes Inspector, and set the identifier (“LoginIdentifier” in my example). Then you can do this:

LoginViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"LoginIdentifier"];
[self.navigationController pushViewController:controller animated:YES];

As a sidenote, I see that you are using capital characters for your methods. You should probably try to avoid that, and instead use lowered first-characters in your method names. And since you say you are learning Objective-C, you should check out this awesome thread here on SO: link.

Update 2:

Here is a zip file with a project showing how to do this. 🙂

Leave a Comment