Note that there are some explanatory texts on larger screens.

plurals
  1. POCan you return data via dismissModalViewControllerAnimated: or do you need a segue for the return journey?
    primarykey
    data
    text
    <p>I've got a <code>ViewController</code>, that has a <code>UIButton</code> which performs the following:</p> <pre><code>- (IBAction)buttonClicked:(id)sender { NSLog(@"Button clicked, lets move to next controller to do stuff"); [self performSegueWithIdentifier:@"toNextController" sender:nil]; } </code></pre> <p>This just moves onto my next <code>ViewController</code>, nothing amazing so far.</p> <p>In the second ViewController, I will do some of my application logic, then return.</p> <pre><code>- (IBAction)backButtonPressed:(id)sender { NSLog(@"Back button clicked, lets just drop out of here..."); [self dismissModalViewControllerAnimated:YES]; } - (IBAction)saveButtonPressed:(id)sender { NSLog(@"save button clicked, lets send some data back"); [self performSegueWithIdentifier:@"backToMain" sender:nil]; } -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"backToMain"]) { NSLog(@"Preparing segue for backToMain"); // Obtain handles on the current and destination controllers MainController * startingViewController; SecondController * destinationController; startingViewController = (MainController * ) segue.sourceViewController; destinationController = (SecondController * ) segue.destinationViewController; // set data on the main controller startingViewController.myString = @"SomeDummyString"; } } </code></pre> <p>What I have tried to do so far, is to create a second segue that links back to the main controller, and before performing the segue, grab a handle on it and set data. I'm not sure if that is the best way of navigating back or not.</p> <p><strong>Question:</strong></p> <p>Is it possible, to return data when doing a <code>[self dismissModalViewControllerAnimated:YES];</code>, or do you need to implement a segue for the return journey?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload