1
votes

I'm trying to call [self.presentingViewController dismissViewControllerAnimated:YES completion:nil] after calling [self presentViewController:modalController animated:YES completion:nil].

Everything works as far as showing and hiding the modal controller but when it is hidden, the presenting controller is showing a different screen.

That presenting controller is a navigation controller and the it basically goes back to the first page displayed.

What am I doing wrong?

Thanks

1

1 Answers

1
votes

The documentation says about dismissViewControllerAnimated:completion:

The presenting view controller is responsible for dismissing the view controller it presented. If you call this method on the presented view controller itself, it automatically forwards the message to the presenting view controller.

If you present several view controllers in succession, thus building a stack of presented view controllers, calling this method on a view controller lower in the stack dismisses its immediate child view controller and all view controllers above that child on the stack. When this happens, only the top-most view is dismissed in an animated fashion; any intermediate view controllers are simply removed from the stack. The top-most view is dismissed using its modal transition style, which may differ from the styles used by other view controllers lower in the stack.

So maybe you are calling this method on the 'wrong' viewcontroller. Try to find out which viewcontroller is returned by self.presentingViewController and / or (just for testing) try to call dismissViewControllerAnimated:completion: on the modal viewcontroller itself.