I have a navigation stack consisting of:
UINavigationViewController
-> WelcomeViewController
-> RoleViewController
I would like to add a modal viewcontroller in between Welcome and Role. I add a ModalViewController via storyboard and assign a segue (Present Modally) to the ModalViewController from a button in WelcomeViewController. It's all good and the modal shows up fine.
Now that I'm inside the ModalViewController I would like to dismiss the modal and perform the original segue from Welcome to Role. I did some searching on StackOverflow and came over different takes on how to do this. The most logical way was set out here: Dismissviewcontroller and perform segue
UIViewController *parentController = self.presentingViewController;
[self dismissViewControllerAnimated:YES completion:^(void){
[parentController performSegueWithIdentifier:@"segue_gotoRole" sender:self];
}];
The modal is dismissed but the segue is not executed and the app crashes:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Receiver (<NavigationViewController: 0x78b96b80>) has no segue
with identifier 'segueToRole''
So the self.presentingViewController targets the UINavigationViewController and not the view controller WelcomeViewController which is actually presenting the modal. To succeed I need to find a way to get the presenting view controller which is defined in the storyboard as the segue originator from within the modal.
I've tried a lot of different combinations, e.g. self.parentViewController, self.presentationViewController, I've even tried to loop through the navigation stack to single out the WelcomeViewController and target it specifically as the object to perform the segue, but nothing seems to work.
Please help me. :)
WelcomeViewController
? – Ozgur Vatansever