views:

142

answers:

2

Hello!

In my iPhone application I have two view controllers that I want to present modally. There is a root controller that presents the first one (say A), and then A presents the second one (say B). Then I want to dismiss both A and B at once, which I do by calling the dismiss… method from the root controller. The documentation states that in this case the whole stack of controllers gets dismissed, both A and B. Both controllers really disappear from the screen, but when I inspect A, its modalViewController property is still set and when I later try once more to present B from A, nothing happens. I solved this situation by calling dismissModalViewControllerAnimated:NO on A before I present A on screen, but that’s a hack, not a real solution. What’s going on, what am I doing wrong?

+1  A: 

Hi ... just wondering if you got an answer to this question. I'm trying to do exactly the same thing .. from main view present modal view that in turn presents a modal view .. need to get rid of both modal views at once.

Gary J
I can get rid of both views at once, but the problem with the `modalViewController` property not getting cleared remains.
zoul
+1  A: 

Hmm. I had no trouble in this situation.

I implemented this with a delegate and protocol, just a method dismissMe: in the parent which handled the dismissal, and a variable in the child to point back to the parent. When root set up A, it told A that root was its delegate; ditto when A set up B.

When B was done, it sent [delegate dismissMe:self]. A's dismissMe: dismissed B unanimated, then sent [delegate dismissMe:self]. Root's dismissMe: then dismissed A unanimated. The visible effect was B giving way right to root.

I can dig out source from my git repo if requested. I went to a different scheme when that app's workflow became more complex.

Joseph Beckenbach
Requesting that you dig out this source, I'm having trouble with this also.
alku83