The best sample I could come up with is the same as the old template in the code.
Add the (nonatomic, weak) UINavigationController *sourceNavigationController to the modal view controller. When the time comes to reject the modal view controller, add the following code:
DetailViewController *detailViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"]; detailViewController.element = newlyCreatedElement; [[self sourceNavigationController] pushViewController:detailViewController animated:NO];
And to make sure the sourceNavigationController parameter sourceNavigationController set correctly, add the following code to prepareForSegue: TableView:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"newElementSegue"]) { [[segue destinationViewController] setSourceNavigationController:self.navigationController]; } }
source share