1

How can I code my view controller to perform a push segue to another view? I know how to do it with the storyboard, but, I can't figure out how to do it with some coding.

user982270
  • 116
  • 2
  • 10
  • Please check this previous post http://stackoverflow.com/questions/15637945/how-do-i-set-a-modal-segue-programmatically-to-a-push-segue – gabo bernal Jan 29 '14 at 12:00

1 Answers1

0

If your view controllers are connected with a segue and if you just want to perform that segue just do:

[self performSegueWithIdentifier:@"identifier" sender:self];

If they're not connected you can set the Storyboard ID of your view controller in the Identity Inspector (⌥⌘3) and use this code to initiate the push segue:

UIViewController *aViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Your Storyboard ID"];
[self.navigationController pushViewController:aViewController animated:YES];

Also, these methods are really useful to manipulate segues:

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
Islam
  • 3,654
  • 3
  • 30
  • 40