Does any know how to get around viewDidAppear not being triggered when exiting from a UIModalTransitionStylePartialCurl segue?

StackOverflow https://stackoverflow.com/questions/15057093

Pregunta

Does any know how to get around viewDidAppear not being hit when exiting from a UIModalTransitionStylePartialCurl segue?

- (IBAction)buttonSelector:(id)sender
{

    // creating object for title screen
    UIStoryboard *storySelection =[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

    // creating object for profile view
    selectorViewController = [storySelection instantiateViewControllerWithIdentifier:@"Verse Selector"];

    // setting the transition style
    selectorViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;

    // performing the segue
    [self presentViewController:selectorViewController animated:YES completion:nil];
}

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    // testing for a return from segue
    if (selectorViewController != nil)
    {
        // getting the chosen values from the instance
        chosenBook = selectorViewController.chosenBook;

        // setting instance to nil for garbage collection
        selectorViewController = nil;
    }
}
¿Fue útil?

Solución

EDIT

It looks like the best route is to implement a custom delegate protocol which notifies the presenting view controller that the presented view controller is being dismissed.

Otros consejos

One way to do this would to be to set your initial view controller as a delegate to your modally presented view controller. Before presenting the view controller:

selectedViewController.delegate = self;
[self presentViewController:selectorViewController animated:YES completion:nil];

Then, in the modal view controller, in whichever method dismisses the modal presentation, directly call viewDidAppear: on the original view controller.

- (void)doneButtonPressed:(id)sender
{
    [self.delegate viewDidAppear:NO];
    [self.delegate dismissModalViewControllerAnimated:YES];
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top