Search code examples
iosobjective-cmodel-view-controlleruiviewcontrollerpopover

Dismiss 2 ViewControllers


I'm making an app whereas a popover ViewController modals to a new ViewController on a button press. When the user is done in the new VC, he/she presses ok and that should be dismissed alongside with the popover ViewController. I tried to use a notification to trigger the popover VC to close, but I can't as the other is being dismissed at the same time.

I see that the dismissing code has a completion token:

[self dismissViewControllerAnimated:YES completion:nil];

How can I set the completion:popoverVC and make that handle it?

Thanks a lot!


Solution

  • You can try:

    [self dismissViewControllerAnimated:YES completion:^{
        [self.parentViewController dismissViewControllerAnimated:YES completion:NULL];
    }];