Is there a way to present two view controllers at once? My scenario is the following:
From my root view controller (View 0)
, I want to modally present a view (View 1)
, and when dismissing that view, a new view (View 2)
should be beneath it.
The view hierarchy would look like so:
- View 1
- View 2
- View 0 (root)
I tried presenting it without animations in -viewDidAppear
in View 1. This does not seem to be called until the presentation animation is finished, though. And presenting it before -viewDidAppear
wouldn't work since the view is not yet in the window hierarchy.
Are there any acceptable ways of doing this?
Presenting a UIViewController
while another UIViewController
is presenting is not possible without stability issues. As a user experience concern, I think that approach would also not be the best. They should know what to expect when they dismiss a view controller.
If you aren't hard set on using presentViewController:
and you have a UINavigationController
, instances of that class have a method setViewControllers:animated:
that allow you push two UIViewControllers
onto a stack. The user would be able to see what they get when they go back (the back item).
Otherwise, you can present on VC, and immediately on success present the other. That's the safest option of doing what you want.