I’m trying to segue in code. the prepareForSegue function runs and shows correct destination view controller, but nothing happens. Any idéas on what I’m missing or what I have misconfigured?
View controller possible path:
A ->B (sgueResultat)
or
A->C (sgueStopSplash)
Code that chooses the segue:
if (proversion)
[self performSegueWithIdentifier:@"sgueResultat" sender:self];
}
else {
[self performSegueWithIdentifier:@"sgueStopSplash" sender:self];
}
`
The prepareForSegue that I can confirm is running by NSLog:
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSLog(@"Source Controller = %@", [segue sourceViewController]);
NSLog(@"Destination Controller = %@", [segue destinationViewController]);
NSLog(@"Segue Identifier = %@", [segue identifier]);
Nslog output:
2012-06-26 22:22:26.002 ClosetV2[2333:fb03] Source Controller = <ABStartViewController: 0xeb12270>
2012-06-26 22:22:26.002 ClosetV2[2333:fb03] Destination Controller = <SplashAfterStopViewController: 0x6b2c9e0>
2012-06-26 22:22:26.003 ClosetV2[2333:fb03] Segue Identifier = sgueStopSplash
2012-06-26 22:22:26.003 ClosetV2[2333:fb03] sgueStopSplash
Regards
Andreas
Make sure your segues are set to “modal” in your storyboard (or custom if you are fancy).
I remember when I first started using segues when storyboarding came out, I kept trying to use push, which you can only do if you have an embedded UINavigationController. Otherwise, a push segue will simply not function.
Another thought… where is the code below executing? If an animation is already taking place or if the current view is not already showing on the screen, it will not function properly. For example, if you have this code in your viewDidLoad, it will not work.
Edit: Updated Answer
Waiting for the [self dismissModalViewController:YES] animation to complete before performing your segue is actually annoying and somewhat messy. I don’t think there is a “proper” way to do it. However, if you put the following method inside the view that has the modal controller and send it a message after using [self dismissModalViewController:YES], you should be in good shape.