1

I am trying to move from one view controller to another when a button is pressed, but it is giving me "sigabrt" error.

This is my code:

-(IBAction)buttonPressed:(id)sender{

     StatsViewController *myStats = [self.storyboard instantiateViewControllerWithIdentifier:@"StatsViewController"];

    [self presentViewController:myStats animated:YES completion:nil];
}

The only reason i am doing it this way is because i need to pass data forward from one view controller to the next.

I also checked my storyboard there are no connections between the two view controllers (just the above code).

However, when i remove the above code and connect the two view controller using the "control drag" method on the storyboard, it works. no error..

user2301717
  • 1,049
  • 1
  • 10
  • 13
  • see if this helps you http://stackoverflow.com/questions/8072135/how-to-track-down-cause-of-sigabrt/8072273#8072273 – Eugene May 03 '13 at 09:02

1 Answers1

1

Make sure that the storyboard instance is not nil and and the Storyboard Id is set properly

-(IBAction)buttonPressed:(id)sender{

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil]; 
StatsViewController *lvc = [storyboard instantiateViewControllerWithIdentifier:@"StatsViewController"];
[self.navigationController pushViewController:lvc animated:YES];

}
Lithu T.V
  • 19,955
  • 12
  • 56
  • 101
  • Thanks man, I spent the past 2 hours trying to solve this problem. NOW I just realised that the I forgot to set the storyboard Id. D: – user2301717 May 03 '13 at 09:08